home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2004 #2 / Amiga Plus CD - 2004 - No. 02.iso / AmiSoft / Misc / emu / Wzonka-Lad.lha / Wzonka-Lad / src / z80_full_III.s < prev    next >
Text File  |  2003-12-25  |  224KB  |  7,984 lines

  1.  
  2. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3. ;        z80 processor emulator, gameboy edition
  4. ;        INPUT:
  5. ;        d0    = 0.W, d.B, e.B.
  6. ;        d1    = 0.W, b.B, c.B.
  7. ;        d2    = 0.W, h.B, l.B.
  8. ;        d3    = 0.W, f.B, a.B.
  9. ;        d4    = 0.W, ccr.W.
  10. ;        d5    = 0.W, sp.W.
  11. ;        a0    = pointer to z80 code.
  12. ;        a1    = base pointer to the z80 jump table.
  13. ;        a2    = base pointer to gameboy memory.
  14. ;        a3    = base pointer to rom switched area.
  15. ;        a4    = base pointer to the z80 $cb jump table.
  16. ;        a5    = the amount of cycles to do.
  17. ;        NOTE:
  18. ;        f    is emulated through amiga's own status register,
  19. ;            so it is not stored as z80's status register, but
  20. ;            a conversion is always executed when needed (rarely).
  21. ;        h    = half carry   flag.
  22. ;        n    = substraction     .
  23. ;        z    = zero             .
  24. ;        c    = carry            .
  25. ;        f    = 000xnzvc (680x0)  .
  26. ;            = znhc0000 (z80)(gb).
  27. ;        680x0    flags = xnzvc--.
  28. ;        z80(gb)    flags = --z-cnh.
  29. ;        f    = 0nhxnzvc (680x0 + emulated xx.B n.6 & h.5).
  30. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  31.  
  32. compute_h:    MACRO
  33.  
  34.         move.b    h_other_I,d6
  35.         move.b    h_other_II,d7
  36.  
  37.         btst    #8,d3                    ;0 = add / 1 = sub.
  38.         beq.s    daa_add_x\@
  39. daa_sub_x\@:    tst.b    h_with_carry                ;0 = no / 1 = yes.
  40.         bne.s    daa_sbc\@
  41. daa_sub\@:    swap    d0
  42.         move.b    d6,d0
  43.         sub.b    d7,d6
  44.         eor.b    d0,d6
  45.         eor.b    d7,d6
  46.         and.b    #$10,d6                    ;d6 = h!
  47.         bra.w    daa_flags\@
  48. daa_sbc\@:    swap    d0
  49.         move.b    d6,d0
  50.         or.b    #$14,CCR                ;x = 1!
  51.         subx.b    d7,d6
  52.         eor.b    d0,d6
  53.         eor.b    d7,d6
  54.         and.b    #$10,d6                    ;d6 = h!
  55.         bra.s    daa_flags\@
  56.  
  57. daa_add_x\@:    tst.b    h_with_carry                ;0 = no / 1 = yes.
  58.         bne.s    daa_adc\@
  59. daa_add\@:    swap    d0
  60.         move.b    d6,d0
  61.         add.b    d7,d6
  62.         eor.b    d0,d6
  63.         eor.b    d7,d6
  64.         and.b    #$10,d6                    ;d6 = h!
  65.         bra.s    daa_flags\@
  66. daa_adc\@:    swap    d0
  67.         move.b    d6,d0
  68.         or.b    #$14,CCR                ;x = 1!
  69.         addx.b    d7,d6
  70.         eor.b    d0,d6
  71.         eor.b    d7,d6
  72.         and.b    #$10,d6                    ;d6 = h!
  73.  
  74. daa_flags\@:    clr.w    d0
  75.         swap    d0
  76.         ENDM
  77.  
  78. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  79. ;        calculate h for the PUSH AF command
  80. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  81.  
  82. calculate_h:    move.l    d6,-(SP)
  83.  
  84.         compute_h                    ;find the flag.
  85.  
  86.         and.w    #$ff,d6
  87.         move.l    (SP)+,d7
  88.         lsl.b    #1,d6                    ;d6 =     (00h00000).
  89.         or.w    d7,d6                    ;d6 =     (znhc0000).
  90.         bra.w    write_d6_stack
  91.  
  92. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  93. ;        execute the DAA command from optcodes
  94. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  95.  
  96. daa_execute:    clr.l    d6
  97.         tst.b    h_the_flag                ;h = 0?
  98.         beq.w    daa_flags_x                ;yes. flags only.
  99.  
  100.         move.b    h_the_flag,d6
  101.         and.b    #1,d6                    ;d6 = h!
  102.         lsl.b    #4,d6                    ;h = h ($10/0).
  103.         bne.w    daa_flags_x                ;h = 1!
  104.  
  105. daa_execute_nor:compute_h
  106.  
  107. ;---------------------------------------------------------------------------------------
  108. ;        DAA FLAG OUTPUTTER AND VALUE ADJUSTER
  109. ;        INPUT:
  110. ;        d6    = h ($10/0).
  111. ;---------------------------------------------------------------------------------------
  112.  
  113. daa_flags_x:    lsr.b    #2,d6                    ;h00.
  114.         move.b    d4,d7
  115.         lsl.b    #1,d7
  116.         and.b    #%10,d7
  117.         clr.l    h_other_I                ;h = 0!
  118.         or.b    d7,d6                    ;hc0.
  119.         ror.w    #8,d3
  120.         lea    daa_jumps(pc),a6
  121.         or.b    d3,d6                    ;hcn.
  122.         rol.w    #8,d3
  123.         jmp    ([a6,d6.l*4])
  124.  
  125.         cnop    0,16
  126. daa_jumps:    dc.l    daa_000
  127.         dc.l    daa_0n0
  128.         dc.l    daa_00c
  129.         dc.l    daa_0nc
  130.         dc.l    daa_h00
  131.         dc.l    daa_hn0
  132.         dc.l    daa_h0c
  133.         dc.l    daa_hnc
  134.  
  135. ;---------------------------------------------------------------------------------------
  136.  
  137. daa_hnc:    move.b    d3,d6
  138.         move.b    d3,d7
  139.         lsr.b    #4,d6                    ;d6 = h.B.
  140.         and.b    #$f,d7                    ;d7 = l.B.
  141.  
  142.         cmp.b    #6,d6                    ;h.
  143.         blt.s    daa_exit_000
  144.         cmp.b    #6,d7                    ;l.
  145.         blt.s    daa_exit_000
  146.  
  147.         add.b    #$9a,d3
  148.         or.b    #%1,d4                    ;c = 1!
  149.  
  150. daa_exit_000:    fetch_next_i
  151.  
  152. ;---------------------------------------------------------------------------------------
  153.  
  154. daa_000:    move.b    d3,d6
  155.         move.b    d3,d7
  156.         lsr.b    #4,d6                    ;d6 = h.B.
  157.         and.b    #$f,d7                    ;d7 = l.B.
  158.  
  159.         cmp.b    #9,d6                    ;h.
  160.         bgt.s    daa_000_2
  161.         cmp.b    #9,d7                    ;l.
  162.         bgt.s    daa_000_2
  163.  
  164. ;        add.b    #$00,d3
  165.         and.b    #%11111110,d4                ;c = 0!
  166.  
  167.         fetch_next_i
  168.  
  169. daa_000_2:    cmp.b    #8,d6                    ;h.
  170.         bgt.s    daa_000_3
  171.         cmp.b    #$A,d7                    ;l.
  172.         blt.s    daa_000_3
  173.  
  174.         add.b    #$06,d3
  175.         and.b    #%11111110,d4                ;c = 0!
  176.  
  177.         fetch_next_i
  178.  
  179. daa_000_3:    cmp.b    #$A,d6                    ;h.
  180.         blt.s    daa_000_4
  181.         cmp.b    #9,d7                    ;l.
  182.         bgt.s    daa_000_4
  183.  
  184.         add.b    #$60,d3
  185.         or.b    #%1,d4                    ;c = 1!
  186.  
  187.         fetch_next_i
  188.  
  189. daa_000_4:    cmp.b    #9,d6                    ;h.
  190.         blt.s    daa_exit_001
  191.         cmp.b    #$A,d7                    ;l.
  192.         blt.s    daa_exit_001
  193.  
  194.         add.b    #$66,d3
  195.         or.b    #%1,d4                    ;c = 1!
  196.  
  197. daa_exit_001:    fetch_next_i
  198.  
  199. ;---------------------------------------------------------------------------------------
  200.  
  201. daa_00c:    move.b    d3,d6
  202.         move.b    d3,d7
  203.         lsr.b    #4,d6                    ;d6 = h.B.
  204.         and.b    #$f,d7                    ;d7 = l.B.
  205.  
  206.         cmp.b    #2,d6                    ;h.
  207.         bgt.s    daa_00c_2
  208.         cmp.b    #9,d7                    ;l.
  209.         bgt.s    daa_00c_2
  210.  
  211.         add.b    #$60,d3
  212.         or.b    #%1,d4                    ;c = 1!
  213.  
  214.         fetch_next_i
  215.  
  216. daa_00c_2:    cmp.b    #2,d6                    ;h.
  217.         bgt.s    daa_exit_002
  218.         cmp.b    #$A,d7                    ;l.
  219.         blt.s    daa_exit_002
  220.  
  221.         add.b    #$66,d3
  222.         or.b    #%1,d4                    ;c = 1!
  223.  
  224. daa_exit_002:    fetch_next_i
  225.  
  226. ;---------------------------------------------------------------------------------------
  227.  
  228. daa_0n0:    move.b    d3,d6
  229.         move.b    d3,d7
  230.         lsr.b    #4,d6                    ;d6 = h.B.
  231.         and.b    #$f,d7                    ;d7 = l.B.
  232.  
  233.         cmp.b    #9,d6                    ;h.
  234.         bgt.s    daa_exit_003
  235.         cmp.b    #9,d7                    ;l.
  236.         bgt.s    daa_exit_003
  237.  
  238. ;        add.b    #$00,d3
  239.         and.b    #%11111110,d4                ;c = 0!
  240.  
  241. daa_exit_003:    fetch_next_i
  242.  
  243. ;---------------------------------------------------------------------------------------
  244.  
  245. daa_0nc:    move.b    d3,d6
  246.         move.b    d3,d7
  247.         lsr.b    #4,d6                    ;d6 = h.B.
  248.         and.b    #$f,d7                    ;d7 = l.B.
  249.  
  250.         cmp.b    #7,d6                    ;h.
  251.         blt.s    daa_exit_004
  252.         cmp.b    #9,d7                    ;l.
  253.         bgt.s    daa_exit_004
  254.  
  255.         add.b    #$a0,d3
  256.         or.b    #%1,d4                    ;c = 1!
  257.  
  258. daa_exit_004:    fetch_next_i
  259.  
  260. ;---------------------------------------------------------------------------------------
  261.  
  262. daa_h00:    move.b    d3,d6
  263.         move.b    d3,d7
  264.         lsr.b    #4,d6                    ;d6 = h.B.
  265.         and.b    #$f,d7                    ;d7 = l.B.
  266.  
  267.         cmp.b    #9,d6                    ;h.
  268.         bgt.s    daa_h00_2
  269.         cmp.b    #3,d7                    ;l.
  270.         bgt.s    daa_h00_2
  271.  
  272.         add.b    #$06,d3
  273.         and.b    #%11111110,d4                ;c = 0!
  274.  
  275.         fetch_next_i
  276.  
  277. daa_h00_2:    cmp.b    #$A,d6                    ;h.
  278.         blt.s    daa_exit_005
  279.         cmp.b    #3,d7                    ;l.
  280.         bgt.s    daa_exit_005
  281.  
  282.         add.b    #$66,d3
  283.         or.b    #%1,d4                    ;c = 1!
  284.  
  285. daa_exit_005:    fetch_next_i
  286.  
  287. ;---------------------------------------------------------------------------------------
  288.  
  289. daa_h0c:    move.b    d3,d6
  290.         move.b    d3,d7
  291.         lsr.b    #4,d6                    ;d6 = h.B.
  292.         and.b    #$f,d7                    ;d7 = l.B.
  293.  
  294.         cmp.b    #3,d6                    ;h.
  295.         bgt.s    daa_exit_006
  296.         cmp.b    #3,d7                    ;l.
  297.         bgt.s    daa_exit_006
  298.  
  299.         add.b    #$66,d3
  300.         or.b    #%1,d4                    ;c = 1!
  301.  
  302. daa_exit_006:    fetch_next_i
  303.  
  304. ;---------------------------------------------------------------------------------------
  305.  
  306. daa_hn0:    move.b    d3,d6
  307.         move.b    d3,d7
  308.         lsr.b    #4,d6                    ;d6 = h.B.
  309.         and.b    #$f,d7                    ;d7 = l.B.
  310.  
  311.         cmp.b    #8,d6                    ;h.
  312.         bgt.s    daa_exit_007
  313.         cmp.b    #6,d7                    ;l.
  314.         blt.s    daa_exit_007
  315.  
  316.         add.b    #$fa,d3
  317.         and.b    #%11111110,d4                ;c = 0!
  318.  
  319. daa_exit_007:    fetch_next_i
  320.  
  321. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  322. ;        trash the oam ram according to the hardware bug
  323. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  324.  
  325. trash_oam_ram:    move.l    a2,a6
  326.         add.l    #$FE08,a6
  327.         moveq.l    #38/2-1,d7
  328.  
  329. trash_oam_ram_loop:
  330.         clr.l    (a6)+
  331.         clr.l    (a6)+
  332.         dbra    d7,trash_oam_ram_loop
  333.         rts
  334.  
  335. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  336. ;        a normal cpu sweep begins here
  337. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  338.  
  339.         cnop    0,4
  340. z80_cpu_sweep:    move.l    z80_cycles,a5                ;a5 = cycles to do.
  341.         moveq.l    #0,d7
  342.         fetch_next_i
  343.  
  344. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  345. ;        the z80 instruction jump table
  346. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  347.  
  348.         cnop    0,128
  349. z80_jump_table:
  350.  
  351. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  352. ;        00 - NOP
  353. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  354.  
  355. z80_optcode_00:    subq.l    #1,a5                    ;less cycles.
  356.  
  357.         fetch_next_i
  358.         cnop    0,128
  359.  
  360. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  361. ;        the z80 extended instruction jump table
  362. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  363.  
  364. z80_jump_tbl_cb:
  365.  
  366. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  367. ;        CB00 - RLC B - [n = 0, h = 0, c = x, z = x]
  368. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  369.  
  370. z80_optc_CB00:    ror.w    #8,d1
  371.         subq.l    #2,a5                    ;less cycles.
  372.         rol.b    #1,d1
  373.         move.w    CCR,d4
  374.         rol.w    #8,d1
  375.  
  376.         clr.l    h_other_I                ;h = 0! no carry!
  377.         and.w    #$ff,d3                    ;n = 0!
  378.  
  379.         fetch_next_i
  380.         cnop    0,128
  381.  
  382. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  383. ;        01 - LD BC, xx
  384. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  385.  
  386. z80_optcode_01:    move.w    (a0)+,d1
  387.         subq.l    #3,a5
  388.         ror.w    #8,d1
  389.  
  390.         fetch_next_i
  391.         cnop    0,128
  392.  
  393. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  394. ;        CB01 - RLC C - [n = 0, h = 0, c = x, z = x]
  395. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  396.  
  397. z80_optc_CB01:    subq.l    #2,a5                    ;less cycles.
  398.         rol.b    #1,d1
  399.         move.w    CCR,d4                    ;status updated.
  400.  
  401.         clr.l    h_other_I                ;h = 0! no carry!
  402.         and.w    #$ff,d3                    ;n = 0!
  403.  
  404.         fetch_next_i
  405.         cnop    0,128
  406.  
  407. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  408. ;        02 - LD (BC), A
  409. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  410.  
  411. z80_optcode_02:    move.b    d3,d6
  412.         move.w    d1,d7
  413.         move.l    gb_mem_jumps,a6
  414.             subq.l    #2,a5
  415.         jsr    ([a6,d1.l*4])
  416.  
  417.         fetch_next_i
  418.         cnop    0,128
  419.  
  420. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  421. ;        CB02 - RLC D - [n = 0, h = 0, c = x, z = x]
  422. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  423.  
  424. z80_optc_CB02:    ror.w    #8,d0                    ;d down.
  425.         subq.l    #2,a5                    ;less cycles.
  426.         rol.b    #1,d0
  427.         move.w    CCR,d4                    ;status updated.
  428.         rol.w    #8,d0                    ;d back to up.
  429.  
  430.         clr.l    h_other_I                ;h = 0! no carry!
  431.         and.w    #$ff,d3                    ;n = 0!
  432.  
  433.         fetch_next_i
  434.         cnop    0,128
  435.  
  436. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  437. ;        03 - INC BC
  438. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  439.  
  440. z80_optcode_03:    subq.l    #2,a5
  441.         cmp.l    #$FE00,d1
  442.         blt.s    z80_optcode_03_ok
  443.         cmp.l    #$FEFF,d1
  444.         bgt.s    z80_optcode_03_ok
  445.  
  446.         bsr.w    trash_oam_ram
  447.  
  448. z80_optcode_03_ok:
  449.         addq.w    #1,d1
  450.  
  451.         fetch_next_i
  452.         cnop    0,128
  453.  
  454. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  455. ;        CB03 - RLC E - [n = 0, h = 0, c = x, z = x]
  456. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  457.  
  458. z80_optc_CB03:    subq.l    #2,a5                    ;less cycles.
  459.         rol.b    #1,d0
  460.         move.w    CCR,d4                    ;status updated.
  461.  
  462.         clr.l    h_other_I                ;h = 0! no carry!
  463.         and.w    #$ff,d3                    ;n = 0!
  464.  
  465.         fetch_next_i
  466.         cnop    0,128
  467.  
  468. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  469. ;        04 - INC B - [n = 0, h = x, c = c, z = x]
  470. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  471.  
  472. z80_optcode_04:    move.l    #$00010002,h_other_I
  473.         ror.w    #8,d1
  474.         subq.l    #1,a5
  475.         move.b    d1,h_other_I
  476.         and.b    #%1,d4
  477.  
  478.         addq.b    #1,d1
  479.         move.w    CCR,d7
  480.         rol.w    #8,d1
  481.         and.b    #%11111110,d7
  482.         and.w    #$ff,d3
  483.         or.b    d7,d4
  484.  
  485.         fetch_next_i
  486.         cnop    0,128
  487.  
  488. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  489. ;        CB04 - RLC H - [n = 0, h = 0, c = x, z = x]
  490. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  491.  
  492. z80_optc_CB04:    ror.w    #8,d2                    ;h down.
  493.         subq.l    #2,a5                    ;less cycles.
  494.         rol.b    #1,d2
  495.         move.w    CCR,d4                    ;status updated.
  496.         rol.w    #8,d2                    ;h back to up.
  497.  
  498.         clr.l    h_other_I                ;h = 0! no carry!
  499.         and.w    #$ff,d3                    ;n = 0!
  500.  
  501.         fetch_next_i
  502.         cnop    0,128
  503.  
  504. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  505. ;        05 - DEC B - [n = 1, h = x, c = c, z = x]
  506. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  507.  
  508. z80_optcode_05:    move.l    #$00010002,h_other_I
  509.         ror.w    #8,d1                    ;b down.
  510.         subq.l    #1,a5                    ;less cycles.
  511.         move.b    d1,h_other_I
  512.         and.b    #%1,d4                    ;save carry.
  513.  
  514.         subq.b    #1,d1                    ;b = b - 1.
  515.         move.w    CCR,d7                    ;status updated.
  516.         rol.w    #8,d1
  517.         and.b    #%11111110,d7                ;c = 0.
  518.         or.w    #$100,d3                ;n = 1!
  519.         or.b    d7,d4                    ;return carry.
  520.  
  521.         fetch_next_i
  522.         cnop    0,128
  523.  
  524. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  525. ;        CB05 - RLC L - [n = 0, h = 0, c = x, z = x]
  526. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  527.  
  528. z80_optc_CB05:    subq.l    #2,a5                    ;less cycles.
  529.         rol.b    #1,d2
  530.         move.w    CCR,d4                    ;status updated.
  531.  
  532.         clr.l    h_other_I                ;h = 0! no carry!
  533.         and.w    #$ff,d3                    ;n = 0!
  534.  
  535.         fetch_next_i
  536.         cnop    0,128
  537.  
  538. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  539. ;        06 - LD B, x
  540. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  541.  
  542. z80_optcode_06:    ror.w    #8,d1                    ;b down.
  543.         subq.l    #2,a5                    ;less cycles.
  544.         move.b    (a0)+,d1
  545.         rol.w    #8,d1                    ;b back to up.
  546.  
  547.         fetch_next_i
  548.         cnop    0,128
  549.  
  550. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  551. ;        CB06 - RLC (HL) - [n = 0, h = 0, c = x, z = x]
  552. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  553.  
  554. z80_optc_CB06:    subq.l    #4,a5
  555.         READ_D2_TO_D6
  556.         rol.b    #1,d6
  557.         move.w    CCR,d4                    ;status updated.
  558.         move.w    d2,d7                    ;d7 = a (hl) - write.
  559.  
  560.         move.l    gb_mem_jumps,a6
  561.         jsr    ([a6,d2.l*4])                ;memory write.
  562.  
  563.         clr.l    h_other_I                ;h = 0! no carry!
  564.         and.w    #$ff,d3                    ;n = 0!
  565.  
  566.         fetch_next_i
  567.         cnop    0,128
  568.  
  569. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  570. ;        07 - RLCA - [n = 0, h = 0, c = x, z = 0]
  571. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  572.  
  573. z80_optcode_07:    subq.l    #1,a5                    ;less cycles.
  574.         rol.b    #1,d3                    ;rotate left c. acc.
  575.         move.w    CCR,d4                    ;status updated.
  576.         clr.l    h_other_I                ;h = 0! no carry!
  577.         and.b    #%1,d4
  578.         and.w    #$ff,d3                    ;n = 0!
  579.  
  580.         fetch_next_i
  581.         cnop    0,128
  582.  
  583. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  584. ;        CB07 - RLC A - [n = 0, h = 0, c = x, z = x]
  585. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  586.  
  587. z80_optc_CB07:    subq.l    #2,a5                    ;less cycles.
  588.         rol.b    #1,d3
  589.         move.w    CCR,d4                    ;status updated.
  590.  
  591.         clr.l    h_other_I                ;h = 0! no carry!
  592.         and.w    #$ff,d3                    ;n = 0!
  593.  
  594.         fetch_next_i
  595.         cnop    0,128
  596.  
  597. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  598. ;        08 - LD (xx), SP
  599. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  600.  
  601. z80_optcode_08:    move.w    (a0)+,d7
  602.         ror.w    #8,d7
  603.         subq.l    #5,a5
  604.         move.l    d7,-(SP)
  605.         move.b    d5,d6
  606.  
  607.         move.l    gb_mem_jumps,a6
  608.         jsr    ([a6,d7.l*4])                ;memory write.
  609.  
  610.         move.l    (SP)+,d7
  611.         move.w    d5,d6
  612.         addq.w    #1,d7                    ;next byte.
  613.         lsr.w    #8,d6                    ;high byte last.
  614.  
  615.         move.l    gb_mem_jumps,a6
  616.         jsr    ([a6,d7.l*4])                ;memory write.
  617.  
  618.         fetch_next_i
  619.         cnop    0,128
  620.  
  621. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  622. ;        CB08 - RRC B - [n = 0, h = 0, c = x, z = x]
  623. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  624.  
  625. z80_optc_CB08:    ror.w    #8,d1                    ;b down.
  626.         subq.l    #2,a5                    ;less cycles.
  627.         ror.b    #1,d1
  628.         move.w    CCR,d4                    ;status updated.
  629.         rol.w    #8,d1                    ;b back to up.
  630.  
  631.         clr.l    h_other_I                ;h = 0! no carry!
  632.         and.w    #$ff,d3                    ;n = 0!
  633.  
  634.         fetch_next_i
  635.         cnop    0,128
  636.  
  637. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  638. ;        09 - ADD HL, BC - [n = 0, h = ?, c = x, z = z]
  639. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  640.  
  641. z80_optcode_09:    and.b    #%11111110,d4                ;c = 0.
  642.         subq.l    #2,a5                    ;less cycles.
  643.  
  644.         move.w    d1,d6
  645.         move.w    d2,d7
  646.         and.w    #%100000000000,d6
  647.         and.w    #%100000000000,d7
  648.         and.w    d6,d7
  649.         lsr.w    #8,d7
  650.         lsr.b    #2,d7
  651.         move.b    d7,h_the_flag                ;h from bits 11.
  652.  
  653.         add.w    d1,d2                    ;add hl, bc.
  654.         move.w    CCR,d7                    ;status updated.
  655.         and.w    #$ff,d3                    ;n = 0!
  656.         and.b    #%1,d7                    ;save carry.
  657.         or.b    d7,d4                    ;return the rest (z).
  658.  
  659.         fetch_next_i
  660.         cnop    0,128
  661.  
  662. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  663. ;        CB09 - RRC C - [n = 0, h = 0, c = x, z = x]
  664. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  665.  
  666. z80_optc_CB09:    subq.l    #2,a5                    ;less cycles.
  667.         ror.b    #1,d1
  668.         move.w    CCR,d4                    ;status updated.
  669.  
  670.         clr.l    h_other_I                ;h = 0! no carry!
  671.         and.w    #$ff,d3                    ;n = 0!
  672.  
  673.         fetch_next_i
  674.         cnop    0,128
  675.  
  676. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  677. ;        0A - LD A, (BC)
  678. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  679.  
  680. z80_optcode_0A:    subq.l    #2,a5                    ;less cycles.
  681.  
  682.         tst.w    d1                    ;rom read?
  683.         blt.s    read_d1_to_d3ax                ;nope. from ram!
  684.         move.b    (a3,d1.l),d3
  685.  
  686.         fetch_next_i
  687.         cnop    0,4
  688.  
  689. read_d1_to_d3ax:move.b    (a2,d1.l),d3                ;ram read.
  690.  
  691.         fetch_next_i
  692.         cnop    0,128
  693.  
  694. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  695. ;        CB0A - RRC D - [n = 0, h = 0, c = x, z = x]
  696. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  697.  
  698. z80_optc_CB0A:    ror.w    #8,d0                    ;d down.
  699.         subq.l    #2,a5                    ;less cycles.
  700.         ror.b    #1,d0
  701.         move.w    CCR,d4                    ;status updated.
  702.         rol.w    #8,d0                    ;d back to up.
  703.  
  704.         clr.l    h_other_I                ;h = 0! no carry!
  705.         and.w    #$ff,d3                    ;n = 0!
  706.  
  707.         fetch_next_i
  708.         cnop    0,128
  709.  
  710. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  711. ;        0B - DEC BC
  712. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  713.  
  714. z80_optcode_0B:    subq.l    #2,a5                    ;less cycles.
  715.         cmp.l    #$FE00,d1
  716.         blt.s    z80_optcode_0B_ok
  717.         cmp.l    #$FEFF,d1
  718.         bgt.s    z80_optcode_0B_ok
  719.  
  720.         bsr.w    trash_oam_ram
  721.  
  722. z80_optcode_0B_ok:
  723.         subq.w    #1,d1                    ;bc = bc - 1.
  724.  
  725.         fetch_next_i
  726.         cnop    0,128
  727.  
  728. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  729. ;        CB0B - RRC E - [n = 0, h = 0, c = x, z = x]
  730. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  731.  
  732. z80_optc_CB0B:    subq.l    #2,a5                    ;less cycles.
  733.         ror.b    #1,d0
  734.         move.w    CCR,d4                    ;status updated.
  735.  
  736.         clr.l    h_other_I                ;h = 0! no carry!
  737.         and.w    #$ff,d3                    ;n = 0!
  738.  
  739.         fetch_next_i
  740.         cnop    0,128
  741.  
  742. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  743. ;        0C - INC C - [n = 0, h = x, c = c, z = x]
  744. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  745.  
  746. z80_optcode_0C:    move.l    #$00010002,h_other_I
  747.         subq.l    #1,a5                    ;less cycles.
  748.         move.b    d1,h_other_I
  749.         and.b    #%1,d4                    ;save carry.
  750.  
  751.         addq.b    #1,d1                    ;c = c + 1.
  752.         move.w    CCR,d7                    ;status updated.
  753.         and.b    #%11111110,d7                ;c = 0.
  754.         and.w    #$ff,d3                    ;n = 0!
  755.         or.b    d7,d4                    ;return carry.
  756.  
  757.         fetch_next_i
  758.         cnop    0,128
  759.  
  760. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  761. ;        CB0C - RRC H - [n = 0, h = 0, c = x, z = x]
  762. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  763.  
  764. z80_optc_CB0C:    ror.w    #8,d2                    ;h down.
  765.         subq.l    #2,a5                    ;less cycles.
  766.         ror.b    #1,d2
  767.         move.w    CCR,d4                    ;status updated.
  768.         rol.w    #8,d2                    ;h back to up.
  769.  
  770.         clr.l    h_other_I                ;h = 0! no carry!
  771.         and.w    #$ff,d3                    ;n = 0!
  772.  
  773.         fetch_next_i
  774.         cnop    0,128
  775.  
  776. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  777. ;        0D - DEC C - [n = 1, h = x, c = c, z = x]
  778. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  779.  
  780. z80_optcode_0D:    move.l    #$00010002,h_other_I
  781.         subq.l    #1,a5                    ;less cycles.
  782.         move.b    d1,h_other_I
  783.         and.b    #%1,d4                    ;save carry.
  784.  
  785.         subq.b    #1,d1                    ;c = c - 1.
  786.         move.w    CCR,d7                    ;status updated.
  787.         and.b    #%11111110,d7                ;c = 0.
  788.         or.w    #$100,d3                ;n = 1!
  789.         or.b    d7,d4                    ;return carry.
  790.  
  791.         fetch_next_i
  792.         cnop    0,128
  793.  
  794. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  795. ;        CB0D - RRC L - [n = 0, h = 0, c = x, z = x]
  796. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  797.  
  798. z80_optc_CB0D:    subq.l    #2,a5                    ;less cycles.
  799.         ror.b    #1,d2
  800.         move.w    CCR,d4                    ;status updated.
  801.  
  802.         clr.l    h_other_I                ;h = 0! no carry!
  803.         and.w    #$ff,d3                    ;n = 0!
  804.  
  805.         fetch_next_i
  806.         cnop    0,128
  807.  
  808. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  809. ;        0E - LD C, x
  810. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  811.  
  812. z80_optcode_0E:    subq.l    #2,a5                    ;less cycles.
  813.         move.b    (a0)+,d1
  814.  
  815.         fetch_next_i
  816.         cnop    0,128
  817.  
  818. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  819. ;        CB0E - RRC (HL) - [n = 0, h = 0, c = x, z = x]
  820. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  821.  
  822. z80_optc_CB0E:    subq.l    #4,a5
  823.         READ_D2_TO_D6
  824.         ror.b    #1,d6
  825.         move.w    CCR,d4                    ;status updated.
  826.         move.w    d2,d7                    ;d7 = a (hl) - write.
  827.  
  828.         move.l    gb_mem_jumps,a6
  829.         jsr    ([a6,d2.l*4])                ;memory write.
  830.  
  831.         clr.l    h_other_I                ;h = 0! no carry!
  832.         and.w    #$ff,d3                    ;n = 0!
  833.  
  834.         fetch_next_i
  835.         cnop    0,128
  836.  
  837. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  838. ;        0F - RRCA - [n = 0, h = 0, c = x, z = 0]
  839. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  840.  
  841. z80_optcode_0F:    subq.l    #1,a5                    ;less cycles.
  842.         ror.b    #1,d3                    ;rotate right c. acc.
  843.         move.w    CCR,d4                    ;status updated.
  844.         and.w    #$ff,d3                    ;n = 0!
  845.         and.b    #%1,d4
  846.         clr.l    h_other_I                ;h = 0! no carry!
  847.  
  848.         fetch_next_i
  849.         cnop    0,128
  850.  
  851. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  852. ;        CB0F - RRC A - [n = 0, h = 0, c = x, z = x]
  853. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  854.  
  855. z80_optc_CB0F:    subq.l    #2,a5                    ;less cycles.
  856.         ror.b    #1,d3
  857.         move.w    CCR,d4                    ;status updated.
  858.  
  859.         clr.l    h_other_I                ;h = 0! no carry!
  860.         and.w    #$ff,d3                    ;n = 0!
  861.  
  862.         fetch_next_i
  863.         cnop    0,128
  864.  
  865. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  866. ;        10 - STOP (+ 00.B?)
  867. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  868.  
  869. z80_optcode_10:    move.b    #1,z80_halt                ;z80 stopped!
  870.         rts
  871.         cnop    0,128
  872.  
  873. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  874. ;        CB10 - RL B - [n = 0, h = 0, c = x, z = x]
  875. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  876.  
  877. z80_optc_CB10:    subq.l    #2,a5                    ;less cycles.
  878.         lsl.b    #4,d4                    ;c = mc680x0's x!
  879.         ror.w    #8,d1
  880.  
  881.         move.w    d4,CCR
  882.         roxl.b    #1,d1
  883.         move.w    CCR,d4
  884.  
  885.         rol.w    #8,d1
  886.         clr.l    h_other_I                ;h = 0! no carry!
  887.         and.w    #$ff,d3                    ;n = 0!
  888.  
  889.         fetch_next_i
  890.         cnop    0,128
  891.  
  892. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  893. ;        11 - LD DE, xx
  894. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  895.  
  896. z80_optcode_11:    move.w    (a0)+,d0
  897.         subq.l    #3,a5
  898.         ror.w    #8,d0
  899.  
  900.         fetch_next_i
  901.         cnop    0,128
  902.  
  903. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  904. ;        CB11 - RL C - [n = 0, h = 0, c = x, z = x]
  905. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  906.  
  907. z80_optc_CB11:    lsl.b    #4,d4                    ;c = mc680x0's x!
  908.         subq.l    #2,a5
  909.  
  910.         move.w    d4,CCR
  911.         roxl.b    #1,d1
  912.         move.w    CCR,d4
  913.  
  914.         clr.l    h_other_I                ;h = 0! no carry!
  915.         and.w    #$ff,d3                    ;n = 0!
  916.  
  917.         fetch_next_i
  918.         cnop    0,128
  919.  
  920. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  921. ;        12 - LD (DE), A
  922. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  923.  
  924. z80_optcode_12:    subq.l    #2,a5                    ;less cycles.
  925.         move.w    d0,d7                    ;d7 = a (de) - write.
  926.         move.b    d3,d6                    ;d6 = a.
  927.  
  928.         move.l    gb_mem_jumps,a6
  929.         jsr    ([a6,d0.l*4])                ;memory write.
  930.  
  931.         fetch_next_i
  932.         cnop    0,128
  933.  
  934. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  935. ;        CB12 - RL D - [n = 0, h = 0, c = x, z = x]
  936. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  937.  
  938. z80_optc_CB12:    subq.l    #2,a5                    ;less cycles.
  939.         lsl.b    #4,d4                    ;c = mc680x0's x!
  940.         ror.w    #8,d0
  941.  
  942.         move.w    d4,CCR
  943.         roxl.b    #1,d0
  944.         move.w    CCR,d4
  945.  
  946.         rol.w    #8,d0
  947.         clr.l    h_other_I                ;h = 0! no carry!
  948.         and.w    #$ff,d3                    ;n = 0!
  949.  
  950.         fetch_next_i
  951.         cnop    0,128
  952.  
  953. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  954. ;        13 - INC DE
  955. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  956.  
  957. z80_optcode_13:    subq.l    #2,a5                    ;less cycles.
  958.         cmp.l    #$FE00,d0
  959.         blt.s    z80_optcode_13_ok
  960.         cmp.l    #$FEFF,d0
  961.         bgt.s    z80_optcode_13_ok
  962.  
  963.         bsr.w    trash_oam_ram
  964.  
  965. z80_optcode_13_ok:
  966.         addq.w    #1,d0                    ;de = de + 1.
  967.  
  968.         fetch_next_i
  969.         cnop    0,128
  970.  
  971. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  972. ;        CB13 - RL E - [n = 0, h = 0, c = x, z = x]
  973. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  974.  
  975. z80_optc_CB13:    lsl.b    #4,d4                    ;c = mc680x0's x!
  976.         subq.l    #2,a5                    ;less cycles.
  977.  
  978.         move.w    d4,CCR
  979.         roxl.b    #1,d0
  980.         move.w    CCR,d4
  981.  
  982.         clr.l    h_other_I                ;h = 0! no carry!
  983.         and.w    #$ff,d3                    ;n = 0!
  984.  
  985.         fetch_next_i
  986.         cnop    0,128
  987.  
  988. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  989. ;        14 - INC D - [n = 0, h = x, c = c, z = x]
  990. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  991.  
  992. z80_optcode_14:    move.l    #$00010002,h_other_I
  993.         ror.w    #8,d0                    ;d down.
  994.         subq.l    #1,a5                    ;less cycles.
  995.         move.b    d0,h_other_I
  996.         and.b    #%1,d4                    ;save carry.
  997.  
  998.         addq.b    #1,d0                    ;d = d + 1.
  999.         move.w    CCR,d7                    ;status updated.
  1000.         rol.w    #8,d0                    ;d back to up.
  1001.         and.b    #%11111110,d7                ;c = 0.
  1002.         and.w    #$ff,d3                    ;n = 0!
  1003.         or.b    d7,d4                    ;return carrry.
  1004.  
  1005.         fetch_next_i
  1006.         cnop    0,128
  1007.  
  1008. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1009. ;        CB14 - RL H - [n = 0, h = 0, c = x, z = x]
  1010. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1011.  
  1012. z80_optc_CB14:    subq.l    #2,a5                    ;less cycles.
  1013.         lsl.b    #4,d4                    ;c = mc680x0's x!
  1014.         ror.w    #8,d2                    ;h down.
  1015.  
  1016.         move.w    d4,CCR
  1017.         roxl.b    #1,d2
  1018.         move.w    CCR,d4
  1019.  
  1020.         rol.w    #8,d2                    ;h back to up.
  1021.         clr.l    h_other_I                ;h = 0! no carry!
  1022.         and.w    #$ff,d3                    ;n = 0!
  1023.  
  1024.         fetch_next_i
  1025.         cnop    0,128
  1026.  
  1027. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1028. ;        15 - DEC D - [n = 1, h = x, c = c, z = x]
  1029. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1030.  
  1031. z80_optcode_15:    move.l    #$00010002,h_other_I
  1032.         ror.w    #8,d0                    ;d down.
  1033.         subq.l    #1,a5                    ;less cycles.
  1034.         move.b    d0,h_other_I
  1035.         and.b    #%1,d4                    ;save carry.
  1036.  
  1037.         subq.b    #1,d0                    ;d = d - 1.
  1038.         move.w    CCR,d7                    ;status updated.
  1039.         rol.w    #8,d0                    ;d back to up.
  1040.         and.b    #%11111110,d7                ;c = 0.
  1041.         or.w    #$100,d3                ;n = 1!
  1042.         or.b    d7,d4                    ;return carry.
  1043.  
  1044.         fetch_next_i
  1045.         cnop    0,128
  1046.  
  1047. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1048. ;        CB15 - RL L - [n = 0, h = 0, c = x, z = x]
  1049. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1050.  
  1051. z80_optc_CB15:    lsl.b    #4,d4                    ;c = mc680x0's x!
  1052.         subq.l    #2,a5                    ;less cycles.
  1053.  
  1054.         move.w    d4,CCR
  1055.         roxl.b    #1,d2
  1056.         move.w    CCR,d4
  1057.  
  1058.         clr.l    h_other_I                ;h = 0! no carry!
  1059.         and.w    #$ff,d3                    ;n = 0!
  1060.  
  1061.         fetch_next_i
  1062.         cnop    0,128
  1063.  
  1064. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1065. ;        16 - LD D, x
  1066. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1067.  
  1068. z80_optcode_16:    ror.w    #8,d0                    ;d down.
  1069.         subq.l    #2,a5                    ;less cycles.
  1070.         move.b    (a0)+,d0
  1071.         rol.w    #8,d0                    ;d back to up.
  1072.  
  1073.         fetch_next_i
  1074.         cnop    0,128
  1075.  
  1076. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1077. ;        CB16 - RL (HL) - [n = 0, h = 0, c = x, z = x]
  1078. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1079.  
  1080. z80_optc_CB16:    subq.l    #4,a5
  1081.         lsl.b    #4,d4                    ;c = mc680x0's x!
  1082.         READ_D2_TO_D6
  1083.  
  1084.         move.w    d4,CCR
  1085.         roxl.b    #1,d6
  1086.         move.w    CCR,d4
  1087.  
  1088.         move.l    gb_mem_jumps,a6
  1089.         move.w    d2,d7
  1090.         jsr    ([a6,d2.l*4])                ;memory write.
  1091.  
  1092.         clr.l    h_other_I                ;h = 0! no carry!
  1093.         and.w    #$ff,d3                    ;n = 0!
  1094.  
  1095.         fetch_next_i
  1096.         cnop    0,128
  1097.  
  1098. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1099. ;        17 - RLA - [n = 0, h = 0, c = x, z = 0]
  1100. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1101.  
  1102. z80_optcode_17:    lsl.b    #4,d4                    ;c = mc680x0's x!
  1103.         subq.l    #1,a5                    ;less cycles.
  1104.  
  1105.         move.w    d4,CCR
  1106.         roxl.b    #1,d3
  1107.         move.w    CCR,d4
  1108.  
  1109.         and.w    #$ff,d3                    ;n = 0!
  1110.         and.b    #%1,d4                    ;z = 0!
  1111.         clr.l    h_other_I                ;h = 0! no carry!
  1112.  
  1113.         fetch_next_i
  1114.         cnop    0,128
  1115.  
  1116. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1117. ;        CB17 - RL A - [n = 0, h = 0, c = x, z = x]
  1118. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1119.  
  1120. z80_optc_CB17:    lsl.b    #4,d4                    ;c = mc680x0's x!
  1121.         subq.l    #2,a5                    ;less cycles.
  1122.  
  1123.         move.w    d4,CCR
  1124.         roxl.b    #1,d3
  1125.         move.w    CCR,d4
  1126.  
  1127.         clr.l    h_other_I                ;h = 0! no carry!
  1128.         and.w    #$ff,d3                    ;n = 0!
  1129.  
  1130.         fetch_next_i
  1131.         cnop    0,128
  1132.  
  1133. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1134. ;        18 - JR x
  1135. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1136.  
  1137. z80_optcode_18:    move.b    (a0)+,d7
  1138.         ext.w    d7
  1139.         subq.l    #2,a5
  1140.         adda.w    d7,a0
  1141.  
  1142.         fetch_next_i
  1143.         cnop    0,128
  1144.  
  1145. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1146. ;        CB18 - RR B - [n = 0, h = 0, c = x, z = x]
  1147. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1148.  
  1149. z80_optc_CB18:    subq.l    #2,a5                    ;less cycles.
  1150.         lsl.b    #4,d4                    ;c = mc680x0's x!
  1151.         ror.w    #8,d1                    ;b down.
  1152.  
  1153.         move.w    d4,CCR
  1154.         roxr.b    #1,d1
  1155.         move.w    CCR,d4
  1156.  
  1157.         rol.w    #8,d1                    ;b back to up.
  1158.         clr.l    h_other_I                ;h = 0! no carry!
  1159.         and.w    #$ff,d3                    ;n = 0!
  1160.  
  1161.         fetch_next_i
  1162.         cnop    0,128
  1163.  
  1164. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1165. ;        19 - ADD HL, DE - [n = 0, h = ?, c = x, z = z]
  1166. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1167.  
  1168. z80_optcode_19:    subq.l    #2,a5                    ;less cycles.
  1169.         and.b    #%11111110,d4                ;save z.
  1170.  
  1171.         move.w    d0,d6
  1172.         move.w    d2,d7
  1173.         and.w    #%100000000000,d6
  1174.         and.w    #%100000000000,d7
  1175.         and.w    d6,d7
  1176.         lsr.w    #8,d7
  1177.         lsr.b    #2,d7
  1178.         move.b    d7,h_the_flag                ;h from bits 11.
  1179.  
  1180.         add.w    d0,d2                    ;hl = hl + de.
  1181.         move.w    CCR,d7                    ;status updated.
  1182.         and.w    #$ff,d3                    ;n = 0!
  1183.         and.b    #%1,d7                    ;save c.
  1184.         or.b    d7,d4                    ;return z.
  1185.  
  1186.         fetch_next_i
  1187.         cnop    0,128
  1188.  
  1189. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1190. ;        CB19 - RR C - [n = 0, h = 0, c = x, z = x]
  1191. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1192.  
  1193. z80_optc_CB19:    subq.l    #2,a5                    ;less cycles.
  1194.         lsl.b    #4,d4                    ;c = mc680x0's x!
  1195.  
  1196.         move.w    d4,CCR
  1197.         roxr.b    #1,d1
  1198.         move.w    CCR,d4
  1199.  
  1200.         clr.l    h_other_I                ;h = 0! no carry!
  1201.         and.w    #$ff,d3                    ;n = 0!
  1202.  
  1203.         fetch_next_i
  1204.         cnop    0,128
  1205.  
  1206. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1207. ;        1A - LD A, (DE)
  1208. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1209.  
  1210. z80_optcode_1A:    subq.l    #2,a5                    ;less cycles.
  1211.  
  1212.         tst.w    d0
  1213.         blt.s    read_d0x_to_d3a                ;nope. from ram!
  1214.         move.b    (a3,d0.l),d3
  1215.  
  1216.         fetch_next_i
  1217.         cnop    0,4
  1218.  
  1219. read_d0x_to_d3a:move.b    (a2,d0.l),d3                ;ram read.
  1220.  
  1221.         fetch_next_i
  1222.         cnop    0,128
  1223.  
  1224. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1225. ;        CB1A - RR D - [n = 0, h = 0, c = x, z = x]
  1226. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1227.  
  1228. z80_optc_CB1A:    subq.l    #2,a5                    ;less cycles.
  1229.         lsl.b    #4,d4                    ;c = mc680x0's x!
  1230.         ror.w    #8,d0                    ;d down.
  1231.  
  1232.         move.w    d4,CCR
  1233.         roxr.b    #1,d0
  1234.         move.w    CCR,d4
  1235.  
  1236.         rol.w    #8,d0                    ;d back to up.
  1237.         clr.l    h_other_I                ;h = 0! no carry!
  1238.         and.w    #$ff,d3                    ;n = 0!
  1239.  
  1240.         fetch_next_i
  1241.         cnop    0,128
  1242.  
  1243. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1244. ;        1B - DEC DE
  1245. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1246.  
  1247. z80_optcode_1B:    subq.l    #2,a5                    ;less cycles.
  1248.         cmp.l    #$FE00,d0
  1249.         blt.s    z80_optcode_1B_ok
  1250.         cmp.l    #$FEFF,d0
  1251.         bgt.s    z80_optcode_1B_ok
  1252.  
  1253.         bsr.w    trash_oam_ram
  1254.  
  1255. z80_optcode_1B_ok:
  1256.         subq.w    #1,d0                    ;de = de - 1.
  1257.  
  1258.         fetch_next_i
  1259.         cnop    0,128
  1260.  
  1261. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1262. ;        CB1B - RR E - [n = 0, h = 0, c = x, z = x]
  1263. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1264.  
  1265. z80_optc_CB1B:    lsl.b    #4,d4                    ;c = mc680x0's x!
  1266.         subq.l    #2,a5                    ;less cycles.
  1267.  
  1268.         move.w    d4,CCR
  1269.         roxr.b    #1,d0
  1270.         move.w    CCR,d4
  1271.  
  1272.         clr.l    h_other_I                ;h = 0! no carry!
  1273.         and.w    #$ff,d3                    ;n = 0!
  1274.  
  1275.         fetch_next_i
  1276.         cnop    0,128
  1277.  
  1278. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1279. ;        1C - INC E - [n = 0, h = x, c = c, z = x]
  1280. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1281.  
  1282. z80_optcode_1C:    move.l    #$00010002,h_other_I
  1283.         subq.l    #1,a5                    ;less cycles.
  1284.         move.b    d0,h_other_I
  1285.         and.b    #%1,d4                    ;save carry.
  1286.  
  1287.         addq.b    #1,d0                    ;e = e + 1.
  1288.         move.w    CCR,d7                    ;status updated.
  1289.         and.b    #%11111110,d7                ;c = 0.
  1290.         and.w    #$ff,d3                    ;n = 0!
  1291.         or.b    d7,d4                    ;return carry.
  1292.  
  1293.         fetch_next_i
  1294.         cnop    0,128
  1295.  
  1296. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1297. ;        CB1C - RR H - [n = 0, h = 0, c = x, z = x]
  1298. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1299.  
  1300. z80_optc_CB1C:    subq.l    #2,a5                    ;less cycles.
  1301.         lsl.b    #4,d4                    ;c = mc680x0's x!
  1302.         ror.w    #8,d2                    ;h down.
  1303.  
  1304.         move.w    d4,CCR
  1305.         roxr.b    #1,d2
  1306.         move.w    CCR,d4
  1307.  
  1308.         rol.w    #8,d2                    ;h back to up.
  1309.         clr.l    h_other_I                ;h = 0! no carry!
  1310.         and.w    #$ff,d3                    ;n = 0!
  1311.  
  1312.         fetch_next_i
  1313.         cnop    0,128
  1314.  
  1315. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1316. ;        1D - DEC E - [n = 1, h = x, c = c, z = x]
  1317. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1318.  
  1319. z80_optcode_1D:    move.l    #$00010002,h_other_I
  1320.         subq.l    #1,a5                    ;less cycles.
  1321.         move.b    d0,h_other_I
  1322.         and.b    #%1,d4                    ;save carry.
  1323.  
  1324.         subq.b    #1,d0                    ;e = e - 1.
  1325.         move.w    CCR,d7                    ;status updated.
  1326.         and.b    #%11111110,d7                ;c = 0.
  1327.         or.w    #$100,d3                ;n = 1!
  1328.         or.b    d7,d4                    ;return carry.
  1329.  
  1330.         fetch_next_i
  1331.         cnop    0,128
  1332.  
  1333. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1334. ;        CB1D - RR L - [n = 0, h = 0, c = x, z = x]
  1335. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1336.  
  1337. z80_optc_CB1D:    lsl.b    #4,d4                    ;c = mc680x0's x!
  1338.         subq.l    #2,a5                    ;less cycles.
  1339.  
  1340.         move.w    d4,CCR
  1341.         roxr.b    #1,d2
  1342.         move.w    CCR,d4
  1343.  
  1344.         clr.l    h_other_I                ;h = 0! no carry!
  1345.         and.w    #$ff,d3                    ;n = 0!
  1346.  
  1347.         fetch_next_i
  1348.         cnop    0,128
  1349.  
  1350. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1351. ;        1E - LD E, x
  1352. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1353.  
  1354. z80_optcode_1E:    subq.l    #2,a5                    ;less cycles.
  1355.         move.b    (a0)+,d0
  1356.  
  1357.         fetch_next_i
  1358.         cnop    0,128
  1359.  
  1360. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1361. ;        CB1E - RR (HL) - [n = 0, h = 0, c = x, z = x]
  1362. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1363.  
  1364. z80_optc_CB1E:    subq.l    #4,a5
  1365.         lsl.b    #4,d4                    ;c = mc680x0's x!
  1366.         READ_D2_TO_D6
  1367.  
  1368.         move.w    d4,CCR
  1369.         roxr.b    #1,d6
  1370.         move.w    CCR,d4
  1371.  
  1372.         move.w    d2,d7                    ;d7 = a (hl) - write.
  1373.  
  1374.         move.l    gb_mem_jumps,a6
  1375.         jsr    ([a6,d2.l*4])                ;memory write.
  1376.  
  1377.         clr.l    h_other_I                ;h = 0! no carry!
  1378.         and.w    #$ff,d3                    ;n = 0!
  1379.  
  1380.         fetch_next_i
  1381.         cnop    0,128
  1382.  
  1383. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1384. ;        1F - RRA - [n = 0, h = 0, c = x, z = 0]
  1385. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1386.  
  1387. z80_optcode_1F:    lsl.b    #4,d4                    ;c = mc680x0's x!
  1388.         subq.l    #1,a5                    ;less cycles.
  1389.  
  1390.         move.w    d4,CCR
  1391.         roxr.b    #1,d3
  1392.         move.w    CCR,d4
  1393.  
  1394.         and.w    #$ff,d3                    ;n = 0!
  1395.         and.b    #%1,d4
  1396.         clr.l    h_other_I                ;h = 0! no carry!
  1397.  
  1398.         fetch_next_i
  1399.         cnop    0,128
  1400.  
  1401. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1402. ;        CB1F - RR A - [n = 0, h = 0, c = x, z = x]
  1403. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1404.  
  1405. z80_optc_CB1F:    lsl.b    #4,d4                    ;c = mc680x0's x!
  1406.         subq.l    #2,a5                    ;less cycles.
  1407.  
  1408.         move.w    d4,CCR
  1409.         roxr.b    #1,d3
  1410.         move.w    CCR,d4
  1411.  
  1412.         clr.l    h_other_I                ;h = 0! no carry!
  1413.         and.w    #$ff,d3                    ;n = 0!
  1414.  
  1415.         fetch_next_i
  1416.         cnop    0,128
  1417.  
  1418. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1419. ;        20 - JR NZ, x
  1420. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1421.  
  1422. z80_optcode_20:    subq.l    #2,a5
  1423.  
  1424.         btst    #2,d4                    ;z - flag set?
  1425.         bne.s    z80_optcode_20x                ;yes. it's zero.
  1426.  
  1427.         move.b    (a0)+,d7
  1428.         ext.w    d7
  1429.         adda.w    d7,a0
  1430.  
  1431.         fetch_next_i
  1432.         cnop    0,4
  1433.  
  1434. z80_optcode_20x:addq.l    #1,a0                    ;no jump.
  1435.  
  1436.         fetch_next_i
  1437.         cnop    0,128
  1438.  
  1439. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1440. ;        CB20 - SLA B - [n = 0, h = 0, c = x, z = x]
  1441. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1442.  
  1443. z80_optc_CB20:    ror.w    #8,d1
  1444.         subq.l    #2,a5                    ;less cycles.
  1445.         asl.b    #1,d1
  1446.         move.w    CCR,d4                    ;status updated.
  1447.         rol.w    #8,d1
  1448.  
  1449.         clr.l    h_other_I                ;h = 0! no carry!
  1450.         and.w    #$ff,d3                    ;n = 0!
  1451.  
  1452.         fetch_next_i
  1453.         cnop    0,128
  1454.  
  1455. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1456. ;        21 - LD HL, xx
  1457. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1458.  
  1459. z80_optcode_21:    move.w    (a0)+,d2
  1460.         subq.l    #3,a5
  1461.         ror.w    #8,d2
  1462.  
  1463.         fetch_next_i
  1464.         cnop    0,128
  1465.  
  1466. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1467. ;        CB21 - SLA C - [n = 0, h = 0, c = x, z = x]
  1468. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1469.  
  1470. z80_optc_CB21:    subq.l    #2,a5                    ;less cycles.
  1471.         asl.b    #1,d1
  1472.         move.w    CCR,d4                    ;status updated.
  1473.  
  1474.         clr.l    h_other_I                ;h = 0! no carry!
  1475.         and.w    #$ff,d3                    ;n = 0!
  1476.  
  1477.         fetch_next_i
  1478.         cnop    0,128
  1479.  
  1480. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1481. ;        22 - LDI (HL), A
  1482. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1483.  
  1484. z80_optcode_22:    subq.l    #2,a5                    ;less cycles.
  1485.         move.w    d2,d7                    ;d7 = a (hl) - write.
  1486.         move.b    d3,d6                    ;d6 = a.
  1487.  
  1488.         move.l    gb_mem_jumps,a6
  1489.         jsr    ([a6,d2.l*4])                ;memory write.
  1490.  
  1491.         cmp.l    #$FE00,d2
  1492.         blt.s    z80_optcode_22_ok
  1493.         cmp.l    #$FEFF,d2
  1494.         bgt.s    z80_optcode_22_ok
  1495.  
  1496.         bsr.w    trash_oam_ram
  1497.  
  1498. z80_optcode_22_ok:
  1499.         addq.w    #1,d2                    ;ldi to hl.
  1500.  
  1501.         fetch_next_i
  1502.         cnop    0,128
  1503.  
  1504. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1505. ;        CB22 - SLA D - [n = 0, h = 0, c = x, z = x]
  1506. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1507.  
  1508. z80_optc_CB22:    ror.w    #8,d0                    ;d down.
  1509.         subq.l    #2,a5                    ;less cycles.
  1510.         asl.b    #1,d0
  1511.         move.w    CCR,d4                    ;status updated.
  1512.         rol.w    #8,d0                    ;d back to up.
  1513.  
  1514.         clr.l    h_other_I                ;h = 0! no carry!
  1515.         and.w    #$ff,d3                    ;n = 0!
  1516.  
  1517.         fetch_next_i
  1518.         cnop    0,128
  1519.  
  1520. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1521. ;        23 - INC HL
  1522. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1523.  
  1524. z80_optcode_23:    subq.l    #2,a5                    ;less cycles.
  1525.         cmp.l    #$FE00,d2
  1526.         blt.s    z80_optcode_23_ok
  1527.         cmp.l    #$FEFF,d2
  1528.         bgt.s    z80_optcode_23_ok
  1529.  
  1530.         bsr.w    trash_oam_ram
  1531.  
  1532. z80_optcode_23_ok:
  1533.         addq.w    #1,d2                    ;hl = hl + 1.
  1534.  
  1535.         fetch_next_i
  1536.         cnop    0,128
  1537.  
  1538. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1539. ;        CB23 - SLA E - [n = 0, h = 0, c = x, z = x]
  1540. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1541.  
  1542. z80_optc_CB23:    subq.l    #2,a5                    ;less cycles.
  1543.         asl.b    #1,d0
  1544.         move.w    CCR,d4                    ;status updated.
  1545.  
  1546.         clr.l    h_other_I                ;h = 0! no carry!
  1547.         and.w    #$ff,d3                    ;n = 0!
  1548.  
  1549.         fetch_next_i
  1550.         cnop    0,128
  1551.  
  1552. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1553. ;        24 - INC H - [n = 0, h = x, c = c, z = x]
  1554. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1555.  
  1556. z80_optcode_24:    move.l    #$00010002,h_other_I
  1557.         ror.w    #8,d2                    ;h down.
  1558.         subq.l    #1,a5                    ;less cycles.
  1559.         move.b    d2,h_other_I
  1560.         and.b    #%1,d4                    ;save carry.
  1561.  
  1562.         addq.b    #1,d2                    ;h = h + 1.
  1563.         move.w    CCR,d7                    ;status updated.
  1564.         rol.w    #8,d2                    ;h back to up.
  1565.         and.b    #%11111110,d7                ;c = 0.
  1566.         and.w    #$ff,d3                    ;n = 0!
  1567.         or.b    d7,d4                    ;return carry.
  1568.  
  1569.         fetch_next_i
  1570.         cnop    0,128
  1571.  
  1572. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1573. ;        CB24 - SLA H - [n = 0, h = 0, c = x, z = x]
  1574. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1575.  
  1576. z80_optc_CB24:    ror.w    #8,d2
  1577.         subq.l    #2,a5                    ;less cycles.
  1578.         asl.b    #1,d2
  1579.         move.w    CCR,d4                    ;status updated.
  1580.         rol.w    #8,d2
  1581.  
  1582.         clr.l    h_other_I                ;h = 0! no carry!
  1583.         and.w    #$ff,d3                    ;n = 0!
  1584.  
  1585.         fetch_next_i
  1586.         cnop    0,128
  1587.  
  1588. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1589. ;        25 - DEC H - [n = 1, h = x, c = c, z = x]
  1590. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1591.  
  1592. z80_optcode_25:    move.l    #$00010002,h_other_I
  1593.         ror.w    #8,d2                    ;h down.
  1594.         subq.l    #1,a5                    ;less cycles.
  1595.         move.b    d2,h_other_I
  1596.         and.b    #%1,d4                    ;save carry.
  1597.  
  1598.         subq.b    #1,d2                    ;h = h - 1.
  1599.         move.w    CCR,d7                    ;status updated.
  1600.         rol.w    #8,d2                    ;h back to up.
  1601.         and.b    #%11111110,d7                ;c = 0.
  1602.         or.w    #$100,d3                ;n = 1!
  1603.         or.b    d7,d4                    ;return carry.
  1604.  
  1605.         fetch_next_i
  1606.         cnop    0,128
  1607.  
  1608. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1609. ;        CB25 - SLA L - [n = 0, h = 0, c = x, z = x]
  1610. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1611.  
  1612. z80_optc_CB25:    subq.l    #2,a5                    ;less cycles.
  1613.         asl.b    #1,d2
  1614.         move.w    CCR,d4                    ;status updated.
  1615.  
  1616.         clr.l    h_other_I                ;h = 0! no carry!
  1617.         and.w    #$ff,d3                    ;n = 0!
  1618.  
  1619.         fetch_next_i
  1620.         cnop    0,128
  1621.  
  1622. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1623. ;        26 - LD H, x
  1624. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1625.  
  1626. z80_optcode_26:    ror.w    #8,d2                    ;h down
  1627.         subq.l    #2,a5                    ;less cycles.
  1628.         move.b    (a0)+,d2
  1629.         rol.w    #8,d2                    ;h back to up.
  1630.  
  1631.         fetch_next_i
  1632.         cnop    0,128
  1633.  
  1634. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1635. ;        CB26 - SLA (HL) - [n = 0, h = 0, c = x, z = x]
  1636. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1637.  
  1638. z80_optc_CB26:    subq.l    #4,a5
  1639.         READ_D2_TO_D6
  1640.         asl.b    #1,d6
  1641.         move.w    CCR,d4                    ;status updated.
  1642.         move.w    d2,d7                    ;d7 = a (hl) - write.
  1643.  
  1644.         move.l    gb_mem_jumps,a6
  1645.         jsr    ([a6,d2.l*4])                ;memory write.
  1646.  
  1647.         clr.l    h_other_I                ;h = 0! no carry!
  1648.         and.w    #$ff,d3                    ;n = 0!
  1649.  
  1650.         fetch_next_i
  1651.         cnop    0,128
  1652.  
  1653. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1654. ;        27 - DAA - [n = n, h = 0, c = x, z = x]
  1655. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1656.  
  1657. z80_optcode_27:    subq.l    #1,a5                    ;less cycles.
  1658.         bra.w    daa_execute                ;more space there.
  1659.         cnop    0,128
  1660.  
  1661. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1662. ;        CB27 - SLA A - [n = 0, h = 0, c = x, z = x]
  1663. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1664.  
  1665. z80_optc_CB27:    subq.l    #2,a5                    ;less cycles.
  1666.         asl.b    #1,d3
  1667.         move.w    CCR,d4                    ;status updated.
  1668.  
  1669.         clr.l    h_other_I                ;h = 0! no carry!
  1670.         and.w    #$ff,d3                    ;n = 0!
  1671.  
  1672.         fetch_next_i
  1673.         cnop    0,128
  1674.  
  1675. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1676. ;        28 - JR Z, x
  1677. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1678.  
  1679. z80_optcode_28:    subq.l    #2,a5
  1680.  
  1681.         btst    #2,d4                    ;z - flag set?
  1682.         beq.s    z80_optcode_28x                ;nope. it's non-zero.
  1683.  
  1684.         move.b    (a0)+,d7
  1685.         ext.w    d7
  1686.         adda.w    d7,a0
  1687.  
  1688.         fetch_next_i
  1689.         cnop    0,4
  1690.  
  1691. z80_optcode_28x:addq.l    #1,a0                    ;no jump.
  1692.  
  1693.         fetch_next_i
  1694.         cnop    0,128
  1695.  
  1696. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1697. ;        CB28 - SRA B - [n = 0, h = 0, c = x, z = x]
  1698. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1699.  
  1700. z80_optc_CB28:    ror.w    #8,d1
  1701.         subq.l    #2,a5                    ;less cycles.
  1702.         asr.b    #1,d1
  1703.         move.w    CCR,d4                    ;status updated.
  1704.         rol.w    #8,d1
  1705.  
  1706.         clr.l    h_other_I                ;h = 0! no carry!
  1707.         and.w    #$ff,d3                    ;n = 0!
  1708.  
  1709.         fetch_next_i
  1710.         cnop    0,128
  1711.  
  1712. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1713. ;        29 - ADD HL, HL - [n = 0, h = ?, c = x, z = z]
  1714. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1715.  
  1716. z80_optcode_29:    subq.l    #2,a5                    ;less cycles.
  1717.         and.b    #%11111110,d4                ;save z.
  1718.  
  1719.         move.w    d2,d7
  1720.         and.w    #%100000000000,d7
  1721.         lsr.w    #8,d7
  1722.         lsr.b    #2,d7
  1723.         move.b    d7,h_the_flag                ;h from bit 11.
  1724.  
  1725.         add.w    d2,d2                    ;hl = hl + hl.
  1726.         move.w    CCR,d7                    ;status updated.
  1727.         and.w    #$ff,d3                    ;n = 0!
  1728.         and.b    #%1,d7                    ;save c.
  1729.         or.b    d7,d4                    ;return z.
  1730.  
  1731.         fetch_next_i
  1732.         cnop    0,128
  1733.  
  1734. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1735. ;        CB29 - SRA C - [n = 0, h = 0, c = x, z = x]
  1736. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1737.  
  1738. z80_optc_CB29:    subq.l    #2,a5                    ;less cycles.
  1739.         asr.b    #1,d1
  1740.         move.w    CCR,d4                    ;status updated.
  1741.  
  1742.         clr.l    h_other_I                ;h = 0! no carry!
  1743.         and.w    #$ff,d3                    ;n = 0!
  1744.  
  1745.         fetch_next_i
  1746.         cnop    0,128
  1747.  
  1748. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1749. ;        2A - LDI A, (HL)
  1750. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1751.  
  1752. z80_optcode_2A:    subq.l    #2,a5                    ;less cycles.
  1753.  
  1754.         cmp.l    #$FE00,d2
  1755.         blt.s    z80_optcode_2A_ok
  1756.         cmp.l    #$FEFF,d2
  1757.         bgt.s    z80_optcode_2A_ok
  1758.  
  1759.         bsr.w    trash_oam_ram
  1760.  
  1761. z80_optcode_2A_ok:
  1762.         tst.w    d2                    ;rom read?
  1763.         blt.s    read_d2_to_d3a1                ;nope. from ram!
  1764.  
  1765.         move.b    (a3,d2.l),d3
  1766.         addq.w    #1,d2                    ;ldi a, (hl).
  1767.  
  1768.         fetch_next_i
  1769.         cnop    0,4
  1770.  
  1771. read_d2_to_d3a1:move.b    (a2,d2.l),d3                ;ram read.
  1772.         addq.w    #1,d2                    ;ldi a, (hl).
  1773.  
  1774.         fetch_next_i
  1775.         cnop    0,128
  1776.  
  1777. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1778. ;        CB2A - SRA D - [n = 0, h = 0, c = x, z = x]
  1779. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1780.  
  1781. z80_optc_CB2A:    ror.w    #8,d0
  1782.         subq.l    #2,a5                    ;less cycles.
  1783.         asr.b    #1,d0
  1784.         move.w    CCR,d4                    ;status updated.
  1785.         rol.w    #8,d0
  1786.  
  1787.         clr.l    h_other_I                ;h = 0! no carry!
  1788.         and.w    #$ff,d3                    ;n = 0!
  1789.  
  1790.         fetch_next_i
  1791.         cnop    0,128
  1792.  
  1793. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1794. ;        2B - DEC HL
  1795. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1796.  
  1797. z80_optcode_2B:    subq.l    #2,a5                    ;less cycles.
  1798.         cmp.l    #$FE00,d2
  1799.         blt.s    z80_optcode_2B_ok
  1800.         cmp.l    #$FEFF,d2
  1801.         bgt.s    z80_optcode_2B_ok
  1802.  
  1803.         bsr.w    trash_oam_ram
  1804.  
  1805. z80_optcode_2B_ok:
  1806.         subq.w    #1,d2                    ;hl = hl - 1.
  1807.  
  1808.         fetch_next_i
  1809.         cnop    0,128
  1810.  
  1811. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1812. ;        CB2B - SRA E - [n = 0, h = 0, c = x, z = x]
  1813. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1814.  
  1815. z80_optc_CB2B:    subq.l    #2,a5                    ;less cycles.
  1816.         asr.b    #1,d0
  1817.         move.w    CCR,d4                    ;status updated.
  1818.  
  1819.         clr.l    h_other_I                ;h = 0! no carry!
  1820.         and.w    #$ff,d3                    ;n = 0!
  1821.  
  1822.         fetch_next_i
  1823.         cnop    0,128
  1824.  
  1825. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1826. ;        2C - INC L - [n = 0, h = x, c = c, z = x]
  1827. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1828.  
  1829. z80_optcode_2C:    move.l    #$00010002,h_other_I
  1830.         subq.l    #1,a5                    ;less cycles.
  1831.         move.b    d2,h_other_I
  1832.         and.b    #%1,d4                    ;save carry.
  1833.  
  1834.         addq.b    #1,d2                    ;l = l + 1.
  1835.         move.w    CCR,d7                    ;status updated.
  1836.         and.b    #%11111110,d7                ;c = 0.
  1837.         and.w    #$ff,d3                    ;n = 0!
  1838.         or.b    d7,d4                    ;return carry.
  1839.  
  1840.         fetch_next_i
  1841.         cnop    0,128
  1842.  
  1843. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1844. ;        CB2C - SRA H - [n = 0, h = 0, c = x, z = x]
  1845. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1846.  
  1847. z80_optc_CB2C:    ror.w    #8,d2                    ;h down.
  1848.         subq.l    #2,a5                    ;less cycles.
  1849.         asr.b    #1,d2
  1850.         move.w    CCR,d4                    ;status updated.
  1851.         rol.w    #8,d2                    ;h back to up.
  1852.  
  1853.         clr.l    h_other_I                ;h = 0! no carry!
  1854.         and.w    #$ff,d3                    ;n = 0!
  1855.  
  1856.         fetch_next_i
  1857.         cnop    0,128
  1858.  
  1859. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1860. ;        2D - DEC L - [n = 1, h = x, c = c, z = x]
  1861. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1862.  
  1863. z80_optcode_2D:    move.l    #$00010002,h_other_I
  1864.         subq.l    #1,a5                    ;less cycles.
  1865.         move.b    d2,h_other_I
  1866.         and.b    #%1,d4                    ;save carry.
  1867.  
  1868.         subq.b    #1,d2                    ;l = l - 1.
  1869.         move.w    CCR,d7                    ;status updated.
  1870.         and.b    #%11111110,d7                ;c = 0.
  1871.         or.w    #$100,d3                ;n = 1!
  1872.         or.b    d7,d4                    ;return carry.
  1873.  
  1874.         fetch_next_i
  1875.         cnop    0,128
  1876.  
  1877. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1878. ;        CB2D - SRA L - [n = 0, h = 0, c = x, z = x]
  1879. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1880.  
  1881. z80_optc_CB2D:    subq.l    #2,a5                    ;less cycles.
  1882.         asr.b    #1,d2
  1883.         move.w    CCR,d4                    ;status updated.
  1884.  
  1885.         clr.l    h_other_I                ;h = 0! no carry!
  1886.         and.w    #$ff,d3                    ;n = 0!
  1887.  
  1888.         fetch_next_i
  1889.         cnop    0,128
  1890.  
  1891. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1892. ;        2E - LD L, x
  1893. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1894.  
  1895. z80_optcode_2E:    subq.l    #2,a5                    ;less cycles.
  1896.         move.b    (a0)+,d2
  1897.  
  1898.         fetch_next_i
  1899.         cnop    0,128
  1900.  
  1901. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1902. ;        CB2E - SRA (HL) - [n = 0, h = 0, c = x, z = x]
  1903. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1904.  
  1905. z80_optc_CB2E:    
  1906.         READ_D2_TO_D6
  1907.  
  1908.         move.w    d2,d7
  1909.         asr.b    #1,d6
  1910.         move.w    CCR,d4                    ;status updated.
  1911.  
  1912.         move.l    gb_mem_jumps,a6
  1913.         subq.l    #4,a5
  1914.         jsr    ([a6,d2.l*4])                ;memory write.
  1915.  
  1916.         clr.l    h_other_I                ;h = 0! no carry!
  1917.         and.w    #$ff,d3                    ;n = 0!
  1918.  
  1919.         fetch_next_i
  1920.         cnop    0,128
  1921.  
  1922. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1923. ;        2F - CPL - [n = 1, h = 1, c = c, z = z]
  1924. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1925.  
  1926. z80_optcode_2F:    subq.l    #1,a5                    ;less cycles.
  1927.         eor.b    #$ff,d3                    ;cpl a.
  1928.         move.b    #1,h_the_flag                ;h = 1!
  1929.         or.w    #$100,d3                ;n = 1!
  1930.  
  1931.         fetch_next_i
  1932.         cnop    0,128
  1933.  
  1934. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1935. ;        CB2F - SRA A - [n = 0, h = 0, c = x, z = x]
  1936. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1937.  
  1938. z80_optc_CB2F:    subq.l    #2,a5                    ;less cycles.
  1939.         asr.b    #1,d3
  1940.         move.w    CCR,d4                    ;status updated.
  1941.  
  1942.         clr.l    h_other_I                ;h = 0! no carry!
  1943.         and.w    #$ff,d3                    ;n = 0!
  1944.  
  1945.         fetch_next_i
  1946.         cnop    0,128
  1947.  
  1948. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1949. ;        30 - JR NC, x
  1950. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1951.  
  1952. z80_optcode_30:    subq.l    #2,a5
  1953.  
  1954.         btst    #0,d4                    ;c - flag set?
  1955.         bne.s    z80_optcode_30x                ;yes. no jump.
  1956.  
  1957.         move.b    (a0)+,d7
  1958.         ext.w    d7
  1959.         adda.w    d7,a0
  1960.  
  1961.         fetch_next_i
  1962.         cnop    0,4
  1963.  
  1964. z80_optcode_30x:addq.l    #1,a0                    ;skip jump.
  1965.  
  1966.         fetch_next_i
  1967.         cnop    0,128
  1968.  
  1969. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1970. ;        CB30 - SWAP B - [n = 0, h = 0, c = 0, z = x]
  1971. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1972.  
  1973. z80_optc_CB30:    subq.l    #2,a5                    ;less cycles.
  1974.         ror.w    #8,d1                    ;b down.
  1975.         ror.b    #4,d1                    ;swap nibbles.
  1976.         move.w    CCR,d4
  1977.         rol.w    #8,d1                    ;b back up.
  1978.         and.b    #%100,d4
  1979.         clr.l    h_other_I                ;h = 0! no carry!
  1980.         and.w    #$ff,d3                    ;n = 0!
  1981.  
  1982.         fetch_next_i
  1983.         cnop    0,128
  1984.  
  1985. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1986. ;        31 - LD SP, xx
  1987. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1988.  
  1989. z80_optcode_31:    move.w    (a0)+,d5
  1990.         subq.l    #3,a5
  1991.         ror.w    #8,d5
  1992.  
  1993.         fetch_next_i
  1994.         cnop    0,128
  1995.  
  1996. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1997. ;        CB31 - SWAP C - [n = 0, h = 0, c = 0, z = x]
  1998. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  1999.  
  2000. z80_optc_CB31:    subq.l    #2,a5                    ;less cycles.
  2001.         ror.b    #4,d1                    ;swap nibbles.
  2002.         move.w    CCR,d4
  2003.         and.b    #%100,d4
  2004.         clr.l    h_other_I                ;h = 0! no carry!
  2005.         and.w    #$ff,d3                    ;n = 0!
  2006.  
  2007.         fetch_next_i
  2008.         cnop    0,128
  2009.  
  2010. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2011. ;        32 - LDD (HL), A
  2012. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2013.  
  2014. z80_optcode_32:    subq.l    #2,a5                    ;less cycles.
  2015.         move.w    d2,d7                    ;d7 = a (hl) - write.
  2016.         move.b    d3,d6                    ;d6 = a.
  2017.  
  2018.         move.l    gb_mem_jumps,a6
  2019.         jsr    ([a6,d2.l*4])                ;memory write.
  2020.  
  2021.         cmp.l    #$FE00,d2
  2022.         blt.s    z80_optcode_32_ok
  2023.         cmp.l    #$FEFF,d2
  2024.         bgt.s    z80_optcode_32_ok
  2025.  
  2026.         bsr.w    trash_oam_ram
  2027.  
  2028. z80_optcode_32_ok:
  2029.         subq.w    #1,d2                    ;ldd to hl.
  2030.  
  2031.         fetch_next_i
  2032.         cnop    0,128
  2033.  
  2034. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2035. ;        CB32 - SWAP D - [n = 0, h = 0, c = 0, z = x]
  2036. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2037.  
  2038. z80_optc_CB32:    subq.l    #2,a5                    ;less cycles.
  2039.         ror.w    #8,d0                    ;d down.
  2040.         ror.b    #4,d0                    ;swap nibbles.
  2041.         move.w    CCR,d4
  2042.         rol.w    #8,d0                    ;d back up.
  2043.         and.b    #%100,d4
  2044.         clr.l    h_other_I                ;h = 0! no carry!
  2045.         and.w    #$ff,d3                    ;n = 0!
  2046.  
  2047.         fetch_next_i
  2048.         cnop    0,128
  2049.  
  2050. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2051. ;        33 - INC SP
  2052. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2053.  
  2054. z80_optcode_33:    subq.l    #2,a5                    ;less cycles.
  2055.         addq.w    #1,d5                    ;sp = sp + 1.
  2056.  
  2057.         fetch_next_i
  2058.         cnop    0,128
  2059.  
  2060. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2061. ;        CB33 - SWAP E - [n = 0, h = 0, c = 0, z = x]
  2062. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2063.  
  2064. z80_optc_CB33:    subq.l    #2,a5                    ;less cycles.
  2065.         ror.b    #4,d0                    ;swap nibbles.
  2066.         move.w    CCR,d4
  2067.         and.b    #%100,d4
  2068.         clr.l    h_other_I                ;h = 0! no carry!
  2069.         and.w    #$ff,d3                    ;n = 0!
  2070.  
  2071.         fetch_next_i
  2072.         cnop    0,128
  2073.  
  2074. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2075. ;        34 - INC (HL) - [n = 0, h = x, c = c, z = x]
  2076. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2077.  
  2078. z80_optcode_34:    move.l    #$00010002,h_other_I
  2079.         READ_D2_TO_D6
  2080.         subq.l    #3,a5
  2081.         move.b    d6,h_other_I
  2082.         and.b    #%1,d4                    ;save carry.
  2083.  
  2084.         addq.b    #1,d6                    ;(hl) = (hl) + 1.
  2085.         move.w    CCR,d7                    ;status updated.
  2086.         and.b    #%11111110,d7                ;c = 0.
  2087.         and.w    #$ff,d3                    ;n = 0!
  2088.         or.b    d7,d4                    ;return carry.
  2089.         move.w    d2,d7                    ;d7 = a (hl) - write.
  2090.  
  2091.         move.l    gb_mem_jumps,a6
  2092.         jsr    ([a6,d2.l*4])                ;memory write.
  2093.  
  2094.         fetch_next_i
  2095.         cnop    0,128
  2096.  
  2097. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2098. ;        CB34 - SWAP H - [n = 0, h = 0, c = 0, z = x]
  2099. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2100.  
  2101. z80_optc_CB34:    subq.l    #2,a5                    ;less cycles.
  2102.         ror.w    #8,d2                    ;h down.
  2103.         ror.b    #4,d2                    ;swap nibbles.
  2104.         move.w    CCR,d4
  2105.         rol.w    #8,d2                    ;h back up.
  2106.         and.b    #%100,d4
  2107.         clr.l    h_other_I                ;h = 0! no carry!
  2108.         and.w    #$ff,d3                    ;n = 0!
  2109.  
  2110.         fetch_next_i
  2111.         cnop    0,128
  2112.  
  2113. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2114. ;        35 - DEC (HL) - [n = 1, h = x, c = c, z = x]
  2115. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2116.  
  2117. z80_optcode_35:    move.l    #$00010002,h_other_I
  2118.         READ_D2_TO_D6
  2119.         subq.l    #3,a5
  2120.         move.b    d6,h_other_I
  2121.         and.b    #%1,d4                    ;save carry.
  2122.  
  2123.         subq.b    #1,d6                    ;(hl) = (hl) - 1.
  2124.         move.w    CCR,d7                    ;status updated.
  2125.         and.b    #%11111110,d7                ;c = 0.
  2126.         or.w    #$100,d3                ;n = 1!
  2127.         or.b    d7,d4                    ;return carry.
  2128.         move.w    d2,d7                    ;d7 = a (hl) - write.
  2129.  
  2130.         move.l    gb_mem_jumps,a6
  2131.         jsr    ([a6,d2.l*4])                ;memory write.
  2132.  
  2133.         fetch_next_i
  2134.         cnop    0,128
  2135.  
  2136. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2137. ;        CB35 - SWAP L - [n = 0, h = 0, c = 0, z = x]
  2138. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2139.  
  2140. z80_optc_CB35:    subq.l    #2,a5                    ;less cycles.
  2141.         ror.b    #4,d2                    ;swap nibbles.
  2142.         move.w    CCR,d4
  2143.         and.b    #%100,d4
  2144.         clr.l    h_other_I                ;h = 0! no carry!
  2145.         and.w    #$ff,d3                    ;n = 0!
  2146.  
  2147.         fetch_next_i
  2148.         cnop    0,128
  2149.  
  2150. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2151. ;        36 - LD (HL), x
  2152. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2153.  
  2154. z80_optcode_36:    move.b    (a0)+,d6
  2155.         subq.l    #3,a5
  2156.         move.l    gb_mem_jumps,a6
  2157.         move.w    d2,d7
  2158.         jsr    ([a6,d2.l*4])
  2159.  
  2160.         fetch_next_i
  2161.         cnop    0,128
  2162.  
  2163. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2164. ;        CB36 - SWAP (HL) - [n = 0, h = 0, c = 0, z = x]
  2165. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2166.  
  2167. z80_optc_CB36:
  2168.         READ_D2_TO_D6
  2169.         subq.l    #4,a5
  2170.         ror.b    #4,d6                    ;swap nibbles.
  2171.         move.w    CCR,d4
  2172.         move.w    d2,d7                    ;d7 = a (hl) - write.
  2173.         and.b    #%100,d4
  2174.  
  2175.         move.l    gb_mem_jumps,a6
  2176.         jsr    ([a6,d2.l*4])                ;memory write.
  2177.  
  2178.         clr.l    h_other_I                ;h = 0! no carry!
  2179.         and.w    #$ff,d3                    ;n = 0!
  2180.  
  2181.         fetch_next_i
  2182.         cnop    0,128
  2183.  
  2184. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2185. ;        37 - SCF - [n = 0, h = 0, c = 1, z = z]
  2186. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2187.  
  2188. z80_optcode_37:    subq.l    #1,a5                    ;less cycles.
  2189.         bset    #0,d4                    ;set carry flag.
  2190.         clr.l    h_other_I                ;h = 0! no carry!
  2191.         and.w    #$ff,d3                    ;n = 0!
  2192.  
  2193.         fetch_next_i
  2194.         cnop    0,128
  2195.  
  2196. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2197. ;        CB37 - SWAP A - [n = 0, h = 0, c = 0, z = x]
  2198. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2199.  
  2200. z80_optc_CB37:    subq.l    #2,a5                    ;less cycles.
  2201.         ror.b    #4,d3                    ;swap nibbles.
  2202.         move.w    CCR,d4
  2203.         and.b    #%100,d4
  2204.         clr.l    h_other_I                ;h = 0! no carry!
  2205.         and.w    #$ff,d3                    ;n = 0!
  2206.  
  2207.         fetch_next_i
  2208.         cnop    0,128
  2209.  
  2210. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2211. ;        38 - JR C, x
  2212. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2213.  
  2214. z80_optcode_38:    subq.l    #2,a5
  2215.  
  2216.         btst    #0,d4                    ;c - flag set?
  2217.         beq.s    z80_optcode_38x                ;no. no jump.
  2218.  
  2219.         move.b    (a0)+,d7
  2220.         ext.w    d7
  2221.         adda.w    d7,a0
  2222.  
  2223.         fetch_next_i
  2224.         cnop    0,4
  2225.  
  2226. z80_optcode_38x:addq.l    #1,a0                    ;skip jump.
  2227.  
  2228.         fetch_next_i
  2229.         cnop    0,128
  2230.  
  2231. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2232. ;        CB38 - SRL B - [n = 0, h = 0, c = x, z = x]
  2233. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2234.  
  2235. z80_optc_CB38:    ror.w    #8,d1
  2236.         subq.l    #2,a5                    ;less cycles.
  2237.         lsr.b    #1,d1
  2238.         move.w    CCR,d4                    ;status updated.
  2239.         rol.w    #8,d1
  2240.  
  2241.         clr.l    h_other_I                ;h = 0! no carry!
  2242.         and.w    #$ff,d3                    ;n = 0!
  2243.  
  2244.         fetch_next_i
  2245.         cnop    0,128
  2246.  
  2247. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2248. ;        39 - ADD HL, SP - [n = 0, h = ?, c = x, z = z]
  2249. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2250.  
  2251. z80_optcode_39:    subq.l    #2,a5                    ;less cycles.
  2252.         and.b    #%11111110,d4                ;save z.
  2253.  
  2254.         move.w    d5,d6
  2255.         move.w    d2,d7
  2256.         and.w    #%100000000000,d6
  2257.         and.w    #%100000000000,d7
  2258.         and.w    d6,d7
  2259.         lsr.w    #8,d7
  2260.         lsr.b    #2,d7
  2261.         move.b    d7,h_the_flag                ;h from bits 11.
  2262.  
  2263.         add.w    d5,d2                    ;hl = hl + sp.
  2264.         move.w    CCR,d7                    ;status updated.
  2265.         and.b    #%1,d7                    ;save carry.
  2266.         and.w    #$ff,d3                    ;n = 0!
  2267.         or.b    d7,d4                    ;return z.
  2268.  
  2269.         fetch_next_i
  2270.         cnop    0,128
  2271.  
  2272. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2273. ;        CB39 - SRL C - [n = 0, h = 0, c = x, z = x]
  2274. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2275.  
  2276. z80_optc_CB39:    subq.l    #2,a5                    ;less cycles.
  2277.         lsr.b    #1,d1
  2278.         move.w    CCR,d4                    ;status updated.
  2279.  
  2280.         clr.l    h_other_I                ;h = 0! no carry!
  2281.         and.w    #$ff,d3                    ;n = 0!
  2282.  
  2283.         fetch_next_i
  2284.         cnop    0,128
  2285.  
  2286. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2287. ;        3A - LDD A, (HL)
  2288. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2289.  
  2290. z80_optcode_3A:    subq.l    #2,a5                    ;less cycles.
  2291.  
  2292.         cmp.l    #$FE00,d2
  2293.         blt.s    z80_optcode_3A_ok
  2294.         cmp.l    #$FEFF,d2
  2295.         bgt.s    z80_optcode_3A_ok
  2296.  
  2297.         bsr.w    trash_oam_ram
  2298.  
  2299. z80_optcode_3A_ok:
  2300.         tst.w    d2                    ;rom read?
  2301.         blt.s    read_d2_to_d3a2                ;nope. from ram!
  2302.  
  2303.         move.b    (a3,d2.l),d3
  2304.         subq.w    #1,d2                    ;ldd a, (hl).
  2305.  
  2306.         fetch_next_i
  2307.         cnop    0,4
  2308.  
  2309. read_d2_to_d3a2:move.b    (a2,d2.l),d3                ;ram read.
  2310.         subq.w    #1,d2                    ;ldd a, (hl).
  2311.  
  2312.         fetch_next_i
  2313.         cnop    0,128
  2314.  
  2315. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2316. ;        CB3A - SRL D - [n = 0, h = 0, c = x, z = x]
  2317. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2318.  
  2319. z80_optc_CB3A:    ror.w    #8,d0                    ;d down.
  2320.         subq.l    #2,a5                    ;less cycles.
  2321.         lsr.b    #1,d0
  2322.         move.w    CCR,d4                    ;status updated.
  2323.         rol.w    #8,d0                    ;d back to up.
  2324.  
  2325.         clr.l    h_other_I                ;h = 0! no carry!
  2326.         and.w    #$ff,d3                    ;n = 0!
  2327.  
  2328.         fetch_next_i
  2329.         cnop    0,128
  2330.  
  2331. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2332. ;        3B - DEC SP
  2333. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2334.  
  2335. z80_optcode_3B:    subq.l    #2,a5                    ;less cycles.
  2336.         subq.w    #1,d5                    ;sp = sp - 1.
  2337.  
  2338.         fetch_next_i
  2339.         cnop    0,128
  2340.  
  2341. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2342. ;        CB3B - SRL E - [n = 0, h = 0, c = x, z = x]
  2343. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2344.  
  2345. z80_optc_CB3B:    subq.l    #2,a5                    ;less cycles.
  2346.         lsr.b    #1,d0
  2347.         move.w    CCR,d4                    ;status updated.
  2348.  
  2349.         clr.l    h_other_I                ;h = 0! no carry!
  2350.         and.w    #$ff,d3                    ;n = 0!
  2351.  
  2352.         fetch_next_i
  2353.         cnop    0,128
  2354.  
  2355. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2356. ;        3C - INC A - [n = 0, h = x, c = c, z = x]
  2357. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2358.  
  2359. z80_optcode_3C:    move.l    #$00010002,h_other_I
  2360.         subq.l    #1,a5                    ;less cycles.
  2361.         move.b    d3,h_other_I
  2362.         and.b    #%1,d4                    ;save carry.
  2363.  
  2364.         addq.b    #1,d3                    ;a = a + 1.
  2365.         move.w    CCR,d7                    ;status updated.
  2366.         and.b    #%11111110,d7                ;c = 0.
  2367.         and.w    #$ff,d3                    ;n = 0!
  2368.         or.b    d7,d4                    ;return carry.
  2369.  
  2370.         fetch_next_i
  2371.         cnop    0,128
  2372.  
  2373. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2374. ;        CB3C - SRL H - [n = 0, h = 0, c = x, z = x]
  2375. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2376.  
  2377. z80_optc_CB3C:    ror.w    #8,d2                    ;h down.
  2378.         subq.l    #2,a5                    ;less cycles.
  2379.         lsr.b    #1,d2
  2380.         move.w    CCR,d4                    ;status updated.
  2381.         rol.w    #8,d2                    ;h back to up.
  2382.  
  2383.         clr.l    h_other_I                ;h = 0! no carry!
  2384.         and.w    #$ff,d3                    ;n = 0!
  2385.  
  2386.         fetch_next_i
  2387.         cnop    0,128
  2388.  
  2389. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2390. ;        3D - DEC A - [n = 1, h = x, c = c, z = x]
  2391. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2392.  
  2393. z80_optcode_3D:    move.l    #$00010002,h_other_I
  2394.         subq.l    #1,a5                    ;less cycles.
  2395.         move.b    d3,h_other_I
  2396.         and.b    #%1,d4                    ;save carry.
  2397.  
  2398.         subq.b    #1,d3                    ;a = a - 1.
  2399.         move.w    CCR,d7                    ;status updated.
  2400.         and.b    #%11111110,d7                ;c = 0.
  2401.         or.w    #$100,d3                ;n = 1!
  2402.         or.b    d7,d4                    ;return carry.
  2403.  
  2404.         fetch_next_i
  2405.         cnop    0,128
  2406.  
  2407. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2408. ;        CB3D - SRL L - [n = 0, h = 0, c = x, z = x]
  2409. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2410.  
  2411. z80_optc_CB3D:    subq.l    #2,a5                    ;less cycles.
  2412.         lsr.b    #1,d2
  2413.         move.w    CCR,d4                    ;status updated.
  2414.  
  2415.         clr.l    h_other_I                ;h = 0! no carry!
  2416.         and.w    #$ff,d3                    ;n = 0!
  2417.  
  2418.         fetch_next_i
  2419.         cnop    0,128
  2420.  
  2421. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2422. ;        3E - LD A, x
  2423. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2424.  
  2425. z80_optcode_3E:    subq.l    #2,a5                    ;less cycles.
  2426.         move.b    (a0)+,d3
  2427.  
  2428.         fetch_next_i
  2429.         cnop    0,128
  2430.  
  2431. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2432. ;        CB3E - SRL (HL) - [n = 0, h = 0, c = x, z = x]
  2433. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2434.  
  2435. z80_optc_CB3E:    subq.l    #4,a5
  2436.         READ_D2_TO_D6
  2437.         lsr.b    #1,d6
  2438.         move.w    CCR,d4                    ;status updated.
  2439.         move.w    d2,d7                    ;d7 = a (hl) - write.
  2440.  
  2441.         move.l    gb_mem_jumps,a6
  2442.         jsr    ([a6,d2.l*4])                ;memory write.
  2443.  
  2444.         clr.l    h_other_I                ;h = 0! no carry!
  2445.         and.w    #$ff,d3                    ;n = 0!
  2446.  
  2447.         fetch_next_i
  2448.         cnop    0,128
  2449.  
  2450. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2451. ;        3F - CCF - [n = 0, h = ?, c = x, z = z]
  2452. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2453.  
  2454. z80_optcode_3F:    subq.l    #1,a5                    ;less cycles.
  2455.         bchg    #0,d4                    ;complement carry flag.
  2456.         move.b    d3,d7
  2457.         and.b    #%1,d7
  2458.         move.b    d7,h_the_flag                ;h = 0/1 (~random).
  2459.  
  2460.         and.w    #$ff,d3                    ;n = 0!
  2461.  
  2462.         fetch_next_i
  2463.         cnop    0,128
  2464.  
  2465. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2466. ;        CB3F - SRL A - [n = 0, h = 0, c = x, z = x]
  2467. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2468.  
  2469. z80_optc_CB3F:    subq.l    #2,a5                    ;less cycles.
  2470.         lsr.b    #1,d3
  2471.         move.w    CCR,d4                    ;status updated.
  2472.  
  2473.         clr.l    h_other_I                ;h = 0! no carry!
  2474.         and.w    #$ff,d3                    ;n = 0!
  2475.  
  2476.         fetch_next_i
  2477.         cnop    0,128
  2478.  
  2479. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2480. ;        40 - LD B, B
  2481. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2482.  
  2483. z80_optcode_40:    subq.l    #1,a5                    ;less cycles.
  2484.  
  2485.         fetch_next_i
  2486.         cnop    0,128
  2487.  
  2488. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2489. ;        CB40 - BIT 0, B - [n = 0, h = 1, c = c, z = x]
  2490. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2491.  
  2492. z80_optc_CB40:    subq.l    #2,a5                    ;less cycles.
  2493.         move.w    d4,CCR                    ;the status register.
  2494.         btst    #8,d1
  2495.         move.w    CCR,d4                    ;status updated.
  2496.  
  2497.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  2498.         and.w    #$ff,d3                    ;n = 0!
  2499.  
  2500.         fetch_next_i
  2501.         cnop    0,128
  2502.  
  2503. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2504. ;        41 - LD B, C
  2505. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2506.  
  2507. z80_optcode_41:    move.b    d1,d7
  2508.         subq.l    #1,a5                    ;less cycles.
  2509.         lsl.w    #8,d1
  2510.         move.b    d7,d1
  2511.  
  2512.         fetch_next_i
  2513.         cnop    0,128
  2514.  
  2515. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2516. ;        CB41 - BIT 0, C - [n = 0, h = 1, c = c, z = x]
  2517. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2518.  
  2519. z80_optc_CB41:    subq.l    #2,a5                    ;less cycles.
  2520.         move.w    d4,CCR                    ;the status register.
  2521.         btst    #0,d1
  2522.         move.w    CCR,d4                    ;status updated.
  2523.  
  2524.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  2525.         and.w    #$ff,d3                    ;n = 0!
  2526.  
  2527.         fetch_next_i
  2528.         cnop    0,128
  2529.  
  2530. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2531. ;        42 - LD B, D
  2532. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2533.  
  2534. z80_optcode_42:    move.b    d1,d7
  2535.         subq.l    #1,a5                    ;less cycles.
  2536.         move.w    d0,d1
  2537.         move.b    d7,d1
  2538.  
  2539.         fetch_next_i
  2540.         cnop    0,128
  2541.  
  2542. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2543. ;        CB42 - BIT 0, D - [n = 0, h = 1, c = c, z = x]
  2544. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2545.  
  2546. z80_optc_CB42:    subq.l    #2,a5                    ;less cycles.
  2547.         move.w    d4,CCR                    ;the status register.
  2548.         btst    #8,d0
  2549.         move.w    CCR,d4                    ;status updated.
  2550.  
  2551.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  2552.         and.w    #$ff,d3                    ;n = 0!
  2553.  
  2554.         fetch_next_i
  2555.         cnop    0,128
  2556.  
  2557. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2558. ;        43 - LD B, E
  2559. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2560.  
  2561. z80_optcode_43:    ror.w    #8,d1
  2562.         subq.l    #1,a5                    ;less cycles.
  2563.         move.b    d0,d1
  2564.         rol.w    #8,d1
  2565.  
  2566.         fetch_next_i
  2567.         cnop    0,128
  2568.  
  2569. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2570. ;        CB43 - BIT 0, E - [n = 0, h = 1, c = c, z = x]
  2571. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2572.  
  2573. z80_optc_CB43:    subq.l    #2,a5                    ;less cycles.
  2574.         move.w    d4,CCR                    ;the status register.
  2575.         btst    #0,d0
  2576.         move.w    CCR,d4                    ;status updated.
  2577.  
  2578.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  2579.         and.w    #$ff,d3                    ;n = 0!
  2580.  
  2581.         fetch_next_i
  2582.         cnop    0,128
  2583.  
  2584. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2585. ;        44 - LD B, H
  2586. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2587.  
  2588. z80_optcode_44:    move.b    d1,d7
  2589.         subq.l    #1,a5                    ;less cycles.
  2590.         move.w    d2,d1
  2591.         move.b    d7,d1
  2592.  
  2593.         fetch_next_i
  2594.         cnop    0,128
  2595.  
  2596. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2597. ;        CB44 - BIT 0, H - [n = 0, h = 1, c = c, z = x]
  2598. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2599.  
  2600. z80_optc_CB44:    subq.l    #2,a5                    ;less cycles.
  2601.         move.w    d4,CCR                    ;the status register.
  2602.         btst    #8,d2
  2603.         move.w    CCR,d4                    ;status updated.
  2604.  
  2605.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  2606.         and.w    #$ff,d3                    ;n = 0!
  2607.  
  2608.         fetch_next_i
  2609.         cnop    0,128
  2610.  
  2611. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2612. ;        45 - LD B, L
  2613. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2614.  
  2615. z80_optcode_45:    rol.w    #8,d1
  2616.         subq.l    #1,a5                    ;less cycles.
  2617.         move.b    d2,d1
  2618.         ror.w    #8,d1
  2619.  
  2620.         fetch_next_i
  2621.         cnop    0,128
  2622.  
  2623. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2624. ;        CB45 - BIT 0, L - [n = 0, h = 1, c = c, z = x]
  2625. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2626.  
  2627. z80_optc_CB45:    subq.l    #2,a5                    ;less cycles.
  2628.         move.w    d4,CCR                    ;the status register.
  2629.         btst    #0,d2
  2630.         move.w    CCR,d4                    ;status updated.
  2631.  
  2632.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  2633.         and.w    #$ff,d3                    ;n = 0!
  2634.  
  2635.         fetch_next_i
  2636.         cnop    0,128
  2637.  
  2638. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2639. ;        46 - LD B, (HL)
  2640. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2641.  
  2642. z80_optcode_46:    ror.w    #8,d1
  2643.         subq.l    #2,a5                    ;less cycles.
  2644.  
  2645.         tst.w    d2                    ;rom read?
  2646.         blt.s    aread_d2_to_d1a                ;nope. from ram!
  2647.         move.b    (a3,d2.l),d1
  2648.         rol.w    #8,d1
  2649.  
  2650.         fetch_next_i
  2651.         cnop    0,4
  2652.  
  2653. aread_d2_to_d1a:move.b    (a2,d2.l),d1                ;ram read.
  2654.         rol.w    #8,d1
  2655.  
  2656.         fetch_next_i
  2657.         cnop    0,128
  2658.  
  2659. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2660. ;        CB46 - BIT 0, (HL) - [n = 0, h = 1, c = c, z = x]
  2661. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2662.  
  2663. z80_optc_CB46:    subq.l    #4,a5
  2664.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  2665.         and.w    #$ff,d3                    ;n = 0!
  2666.  
  2667.         tst.w    d2                    ;rom read?
  2668.         blt.s    read_d2a_to_d7a                ;nope. from ram!
  2669.  
  2670.         move.w    d4,CCR                    ;the status register.
  2671.         btst.b    #0,(a3,d2.l)
  2672.         move.w    CCR,d4                    ;status updated.
  2673.  
  2674.         fetch_next_i
  2675.         cnop    0,4
  2676.  
  2677. read_d2a_to_d7a:move.w    d4,CCR                    ;the status register.
  2678.         btst.b    #0,(a2,d2.l)                ;ram read.
  2679.         move.w    CCR,d4                    ;status updated.
  2680.  
  2681.         fetch_next_i
  2682.         cnop    0,128
  2683.  
  2684. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2685. ;        47 - LD B, A
  2686. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2687.  
  2688. z80_optcode_47:    ror.w    #8,d1
  2689.         subq.l    #1,a5                    ;less cycles.
  2690.         move.b    d3,d1
  2691.         rol.w    #8,d1
  2692.  
  2693.         fetch_next_i
  2694.         cnop    0,128
  2695.  
  2696. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2697. ;        CB47 - BIT 0, A - [n = 0, h = 1, c = c, z = x]
  2698. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2699.  
  2700. z80_optc_CB47:    subq.l    #2,a5                    ;less cycles.
  2701.         move.w    d4,CCR                    ;the status register.
  2702.         btst    #0,d3
  2703.         move.w    CCR,d4                    ;status updated.
  2704.  
  2705.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  2706.         and.w    #$ff,d3                    ;n = 0!
  2707.  
  2708.         fetch_next_i
  2709.         cnop    0,128
  2710.  
  2711. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2712. ;        48 - LD C, B
  2713. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2714.  
  2715. z80_optcode_48:    move.w    d1,d7
  2716.         subq.l    #1,a5                    ;less cycles.
  2717.         lsr.w    #8,d7
  2718.         move.b    d7,d1
  2719.  
  2720.         fetch_next_i
  2721.         cnop    0,128
  2722.  
  2723. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2724. ;        CB48 - BIT 1, B - [n = 0, h = 1, c = c, z = x]
  2725. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2726.  
  2727. z80_optc_CB48:    subq.l    #2,a5                    ;less cycles.
  2728.         move.w    d4,CCR                    ;the status register.
  2729.         btst    #9,d1
  2730.         move.w    CCR,d4                    ;status updated.
  2731.  
  2732.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  2733.         and.w    #$ff,d3                    ;n = 0!
  2734.  
  2735.         fetch_next_i
  2736.         cnop    0,128
  2737.  
  2738. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2739. ;        49 - LD C, C
  2740. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2741.  
  2742. z80_optcode_49:    subq.l    #1,a5                    ;less cycles.
  2743.  
  2744.         fetch_next_i
  2745.         cnop    0,128
  2746.  
  2747. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2748. ;        CB49 - BIT 1, C - [n = 0, h = 1, c = c, z = x]
  2749. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2750.  
  2751. z80_optc_CB49:    subq.l    #2,a5                    ;less cycles.
  2752.         move.w    d4,CCR                    ;the status register.
  2753.         btst    #1,d1
  2754.         move.w    CCR,d4                    ;status updated.
  2755.  
  2756.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  2757.         and.w    #$ff,d3                    ;n = 0!
  2758.  
  2759.         fetch_next_i
  2760.         cnop    0,128
  2761.  
  2762. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2763. ;        4A - LD C, D
  2764. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2765.  
  2766. z80_optcode_4A:    move.w    d0,d7
  2767.         subq.l    #1,a5                    ;less cycles.
  2768.         lsr.w    #8,d7
  2769.         move.b    d7,d1
  2770.  
  2771.         fetch_next_i
  2772.         cnop    0,128
  2773.  
  2774. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2775. ;        CB4A - BIT 1, D - [n = 0, h = 1, c = c, z = x]
  2776. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2777.  
  2778. z80_optc_CB4A:    subq.l    #2,a5                    ;less cycles.
  2779.         move.w    d4,CCR                    ;the status register.
  2780.         btst    #9,d0
  2781.         move.w    CCR,d4                    ;status updated.
  2782.  
  2783.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  2784.         and.w    #$ff,d3                    ;n = 0!
  2785.  
  2786.         fetch_next_i
  2787.         cnop    0,128
  2788.  
  2789. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2790. ;        4B - LD C, E
  2791. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2792.  
  2793. z80_optcode_4B:    subq.l    #1,a5                    ;less cycles.
  2794.         move.b    d0,d1
  2795.  
  2796.         fetch_next_i
  2797.         cnop    0,128
  2798.  
  2799. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2800. ;        CB4B - BIT 1, E - [n = 0, h = 1, c = c, z = x]
  2801. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2802.  
  2803. z80_optc_CB4B:    subq.l    #2,a5                    ;less cycles.
  2804.         move.w    d4,CCR                    ;the status register.
  2805.         btst    #1,d0
  2806.         move.w    CCR,d4                    ;status updated.
  2807.  
  2808.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  2809.         and.w    #$ff,d3                    ;n = 0!
  2810.  
  2811.         fetch_next_i
  2812.         cnop    0,128
  2813.  
  2814. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2815. ;        4C - LD C, H
  2816. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2817.  
  2818. z80_optcode_4C:    move.w    d2,d7
  2819.         subq.l    #1,a5                    ;less cycles.
  2820.         lsr.w    #8,d7
  2821.         move.b    d7,d1
  2822.  
  2823.         fetch_next_i
  2824.         cnop    0,128
  2825.  
  2826. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2827. ;        CB4C - BIT 1, H - [n = 0, h = 1, c = c, z = x]
  2828. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2829.  
  2830. z80_optc_CB4C:    subq.l    #2,a5                    ;less cycles.
  2831.         move.w    d4,CCR                    ;the status register.
  2832.         btst    #9,d2
  2833.         move.w    CCR,d4                    ;status updated.
  2834.  
  2835.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  2836.         and.w    #$ff,d3                    ;n = 0!
  2837.  
  2838.         fetch_next_i
  2839.         cnop    0,128
  2840.  
  2841. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2842. ;        4D - LD C, L
  2843. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2844.  
  2845. z80_optcode_4D:    subq.l    #1,a5                    ;less cycles.
  2846.         move.b    d2,d1
  2847.  
  2848.         fetch_next_i
  2849.         cnop    0,128
  2850.  
  2851. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2852. ;        CB4D - BIT 1, L - [n = 0, h = 1, c = c, z = x]
  2853. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2854.  
  2855. z80_optc_CB4D:    subq.l    #2,a5                    ;less cycles.
  2856.         move.w    d4,CCR                    ;the status register.
  2857.         btst    #1,d2
  2858.         move.w    CCR,d4                    ;status updated.
  2859.  
  2860.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  2861.         and.w    #$ff,d3                    ;n = 0!
  2862.  
  2863.         fetch_next_i
  2864.         cnop    0,128
  2865.  
  2866. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2867. ;        4E - LD C, (HL)
  2868. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2869.  
  2870. z80_optcode_4E:    subq.l    #2,a5                    ;less cycles.
  2871.  
  2872.         tst.w    d2                    ;rom read?
  2873.         blt.s    bread_d2_to_d1a                ;nope. from ram!
  2874.         move.b    (a3,d2.l),d1
  2875.  
  2876.         fetch_next_i
  2877.         cnop    0,4
  2878.  
  2879. bread_d2_to_d1a:move.b    (a2,d2.l),d1                ;ram read.
  2880.  
  2881.         fetch_next_i
  2882.         cnop    0,128
  2883.  
  2884. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2885. ;        CB4E - BIT 1, (HL) - [n = 0, h = 1, c = c, z = x]
  2886. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2887.  
  2888. z80_optc_CB4E:    subq.l    #4,a5
  2889.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  2890.         and.w    #$ff,d3                    ;n = 0!
  2891.  
  2892.         tst.w    d2                    ;rom read?
  2893.         blt.s    read_d2b_to_d7a                ;nope. from ram!
  2894.  
  2895.         move.w    d4,CCR                    ;the status register.
  2896.         btst.b    #1,(a3,d2.l)
  2897.         move.w    CCR,d4                    ;status updated.
  2898.  
  2899.         fetch_next_i
  2900.         cnop    0,4
  2901.  
  2902. read_d2b_to_d7a:move.w    d4,CCR                    ;the status register.
  2903.         btst.b    #1,(a2,d2.l)                ;ram read.
  2904.         move.w    CCR,d4                    ;status updated.
  2905.  
  2906.         fetch_next_i
  2907.         cnop    0,128
  2908.  
  2909. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2910. ;        4F - LD C, A
  2911. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2912.  
  2913. z80_optcode_4F:    subq.l    #1,a5                    ;less cycles.
  2914.         move.b    d3,d1
  2915.  
  2916.         fetch_next_i
  2917.         cnop    0,128
  2918.  
  2919. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2920. ;        CB4F - BIT 1, A - [n = 0, h = 1, c = c, z = x]
  2921. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2922.  
  2923. z80_optc_CB4F:    subq.l    #2,a5                    ;less cycles.
  2924.         move.w    d4,CCR                    ;the status register.
  2925.         btst    #1,d3
  2926.         move.w    CCR,d4                    ;status updated.
  2927.  
  2928.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  2929.         and.w    #$ff,d3                    ;n = 0!
  2930.  
  2931.         fetch_next_i
  2932.         cnop    0,128
  2933.  
  2934. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2935. ;        50 - LD D, B
  2936. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2937.  
  2938. z80_optcode_50:    move.b    d0,d7
  2939.         subq.l    #1,a5                    ;less cycles.
  2940.         move.w    d1,d0
  2941.         move.b    d7,d0
  2942.  
  2943.         fetch_next_i
  2944.         cnop    0,128
  2945.  
  2946. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2947. ;        CB50 - BIT 2, B - [n = 0, h = 1, c = c, z = x]
  2948. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2949.  
  2950. z80_optc_CB50:    subq.l    #2,a5                    ;less cycles.
  2951.         move.w    d4,CCR                    ;the status register.
  2952.         btst    #10,d1
  2953.         move.w    CCR,d4                    ;status updated.
  2954.  
  2955.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  2956.         and.w    #$ff,d3                    ;n = 0!
  2957.  
  2958.         fetch_next_i
  2959.         cnop    0,128
  2960.  
  2961. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2962. ;        51 - LD D, C
  2963. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2964.  
  2965. z80_optcode_51:    ror.w    #8,d0
  2966.         subq.l    #1,a5                    ;less cycles.
  2967.         move.b    d1,d0
  2968.         rol.w    #8,d0
  2969.  
  2970.         fetch_next_i
  2971.         cnop    0,128
  2972.  
  2973. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2974. ;        CB51 - BIT 2, C - [n = 0, h = 1, c = c, z = x]
  2975. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2976.  
  2977. z80_optc_CB51:    subq.l    #2,a5                    ;less cycles.
  2978.         move.w    d4,CCR                    ;the status register.
  2979.         btst    #2,d1
  2980.         move.w    CCR,d4                    ;status updated.
  2981.  
  2982.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  2983.         and.w    #$ff,d3                    ;n = 0!
  2984.  
  2985.         fetch_next_i
  2986.         cnop    0,128
  2987.  
  2988. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2989. ;        52 - LD D, D
  2990. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2991.  
  2992. z80_optcode_52:    subq.l    #1,a5                    ;less cycles.
  2993.  
  2994.         fetch_next_i
  2995.         cnop    0,128
  2996.  
  2997. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  2998. ;        CB52 - BIT 2, D - [n = 0, h = 1, c = c, z = x]
  2999. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3000.  
  3001. z80_optc_CB52:    subq.l    #2,a5                    ;less cycles.
  3002.         move.w    d4,CCR                    ;the status register.
  3003.         btst    #10,d0
  3004.         move.w    CCR,d4                    ;status updated.
  3005.  
  3006.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3007.         and.w    #$ff,d3                    ;n = 0!
  3008.  
  3009.         fetch_next_i
  3010.         cnop    0,128
  3011.  
  3012. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3013. ;        53 - LD D, E
  3014. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3015.  
  3016. z80_optcode_53:    move.b    d0,d7
  3017.         subq.l    #1,a5                    ;less cycles.
  3018.         lsl.w    #8,d0
  3019.         move.b    d7,d0
  3020.  
  3021.         fetch_next_i
  3022.         cnop    0,128
  3023.  
  3024. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3025. ;        CB53 - BIT 2, E - [n = 0, h = 1, c = c, z = x]
  3026. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3027.  
  3028. z80_optc_CB53:    subq.l    #2,a5                    ;less cycles.
  3029.         move.w    d4,CCR                    ;the status register.
  3030.         btst    #2,d0
  3031.         move.w    CCR,d4                    ;status updated.
  3032.  
  3033.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3034.         and.w    #$ff,d3                    ;n = 0!
  3035.  
  3036.         fetch_next_i
  3037.         cnop    0,128
  3038.  
  3039. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3040. ;        54 - LD D, H
  3041. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3042.  
  3043. z80_optcode_54:    move.b    d0,d7
  3044.         subq.l    #1,a5                    ;less cycles.
  3045.         move.w    d2,d0
  3046.         move.b    d7,d0
  3047.  
  3048.         fetch_next_i
  3049.         cnop    0,128
  3050.  
  3051. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3052. ;        CB54 - BIT 2, H - [n = 0, h = 1, c = c, z = x]
  3053. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3054.  
  3055. z80_optc_CB54:    subq.l    #2,a5                    ;less cycles.
  3056.         move.w    d4,CCR                    ;the status register.
  3057.         btst    #10,d2
  3058.         move.w    CCR,d4                    ;status updated.
  3059.  
  3060.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3061.         and.w    #$ff,d3                    ;n = 0!
  3062.  
  3063.         fetch_next_i
  3064.         cnop    0,128
  3065.  
  3066. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3067. ;        55 - LD D, L
  3068. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3069.  
  3070. z80_optcode_55:    ror.w    #8,d0
  3071.         subq.l    #1,a5                    ;less cycles.
  3072.         move.b    d2,d0
  3073.         rol.w    #8,d0
  3074.  
  3075.         fetch_next_i
  3076.         cnop    0,128
  3077.  
  3078. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3079. ;        CB55 - BIT 2, L - [n = 0, h = 1, c = c, z = x]
  3080. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3081.  
  3082. z80_optc_CB55:    subq.l    #2,a5                    ;less cycles.
  3083.         move.w    d4,CCR                    ;the status register.
  3084.         btst    #2,d2
  3085.         move.w    CCR,d4                    ;status updated.
  3086.  
  3087.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3088.         and.w    #$ff,d3                    ;n = 0!
  3089.  
  3090.         fetch_next_i
  3091.         cnop    0,128
  3092.  
  3093. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3094. ;        56 - LD D, (HL)
  3095. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3096.  
  3097. z80_optcode_56:    ror.w    #8,d0                    ;d down.
  3098.         subq.l    #2,a5                    ;less cycles.
  3099.  
  3100.         tst.w    d2                    ;rom read?
  3101.         blt.s    cread_d2_to_d0a                ;nope. from ram!
  3102.         move.b    (a3,d2.l),d0
  3103.         rol.w    #8,d0                    ;d back to up.
  3104.     
  3105.         fetch_next_i
  3106.         cnop    0,4
  3107.  
  3108. cread_d2_to_d0a:move.b    (a2,d2.l),d0                ;ram read.
  3109.         rol.w    #8,d0                    ;d back to up.
  3110.  
  3111.         fetch_next_i
  3112.         cnop    0,128
  3113.  
  3114. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3115. ;        CB56 - BIT 2, (HL) - [n = 0, h = 1, c = c, z = x]
  3116. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3117.  
  3118. z80_optc_CB56:    subq.l    #4,a5
  3119.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3120.         and.w    #$ff,d3                    ;n = 0!
  3121.  
  3122.         tst.w    d2                    ;rom read?
  3123.         blt.s    read_d2c_to_d7a                ;nope. from ram!
  3124.  
  3125.         move.w    d4,CCR                    ;the status register.
  3126.         btst.b    #2,(a3,d2.l)
  3127.         move.w    CCR,d4                    ;status updated.
  3128.  
  3129.         fetch_next_i
  3130.         cnop    0,4
  3131.  
  3132. read_d2c_to_d7a:move.w    d4,CCR                    ;the status register.
  3133.         btst.b    #2,(a2,d2.l)                ;ram read.
  3134.         move.w    CCR,d4                    ;status updated.
  3135.  
  3136.         fetch_next_i
  3137.         cnop    0,128
  3138.  
  3139. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3140. ;        57 - LD D, A
  3141. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3142.  
  3143. z80_optcode_57:    ror.w    #8,d0
  3144.         subq.l    #1,a5                    ;less cycles.
  3145.         move.b    d3,d0
  3146.         rol.w    #8,d0
  3147.  
  3148.         fetch_next_i
  3149.         cnop    0,128
  3150.  
  3151. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3152. ;        CB57 - BIT 2, A - [n = 0, h = 1, c = c, z = x]
  3153. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3154.  
  3155. z80_optc_CB57:    subq.l    #2,a5                    ;less cycles.
  3156.         move.w    d4,CCR                    ;the status register.
  3157.         btst    #2,d3
  3158.         move.w    CCR,d4                    ;status updated.
  3159.  
  3160.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3161.         and.w    #$ff,d3                    ;n = 0!
  3162.  
  3163.         fetch_next_i
  3164.         cnop    0,128
  3165.  
  3166. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3167. ;        58 - LD E, B
  3168. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3169.  
  3170. z80_optcode_58:    move.w    d1,d7
  3171.         subq.l    #1,a5                    ;less cycles.
  3172.         lsr.w    #8,d7
  3173.         move.b    d7,d0
  3174.  
  3175.         fetch_next_i
  3176.         cnop    0,128
  3177.  
  3178. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3179. ;        CB58 - BIT 3, B - [n = 0, h = 1, c = c, z = x]
  3180. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3181.  
  3182. z80_optc_CB58:    subq.l    #2,a5                    ;less cycles.
  3183.         move.w    d4,CCR                    ;the status register.
  3184.         btst    #11,d1
  3185.         move.w    CCR,d4                    ;status updated.
  3186.  
  3187.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3188.         and.w    #$ff,d3                    ;n = 0!
  3189.  
  3190.         fetch_next_i
  3191.         cnop    0,128
  3192.  
  3193. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3194. ;        59 - LD E, C
  3195. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3196.  
  3197. z80_optcode_59:    move.b    d1,d0
  3198.         subq.l    #1,a5                    ;less cycles.
  3199.  
  3200.         fetch_next_i
  3201.         cnop    0,128
  3202.  
  3203. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3204. ;        CB59 - BIT 3, C - [n = 0, h = 1, c = c, z = x]
  3205. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3206.  
  3207. z80_optc_CB59:    subq.l    #2,a5                    ;less cycles.
  3208.         move.w    d4,CCR                    ;the status register.
  3209.         btst    #3,d1
  3210.         move.w    CCR,d4                    ;status updated.
  3211.  
  3212.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3213.         and.w    #$ff,d3                    ;n = 0!
  3214.  
  3215.         fetch_next_i
  3216.         cnop    0,128
  3217.  
  3218. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3219. ;        5A - LD E, D
  3220. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3221.  
  3222. z80_optcode_5A:    move.w    d0,d7
  3223.         subq.l    #1,a5                    ;less cycles.
  3224.         lsr.w    #8,d7
  3225.         move.b    d7,d0
  3226.  
  3227.         fetch_next_i
  3228.         cnop    0,128
  3229.  
  3230. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3231. ;        CB5A - BIT 3, D - [n = 0, h = 1, c = c, z = x]
  3232. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3233.  
  3234. z80_optc_CB5A:    subq.l    #2,a5                    ;less cycles.
  3235.         move.w    d4,CCR                    ;the status register.
  3236.         btst    #11,d0
  3237.         move.w    CCR,d4                    ;status updated.
  3238.  
  3239.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3240.         and.w    #$ff,d3                    ;n = 0!
  3241.  
  3242.         fetch_next_i
  3243.         cnop    0,128
  3244.  
  3245. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3246. ;        5B - LD E, E
  3247. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3248.  
  3249. z80_optcode_5B:    subq.l    #1,a5                    ;less cycles.
  3250.  
  3251.         fetch_next_i
  3252.         cnop    0,128
  3253.  
  3254. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3255. ;        CB5B - BIT 3, E - [n = 0, h = 1, c = c, z = x]
  3256. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3257.  
  3258. z80_optc_CB5B:    subq.l    #2,a5                    ;less cycles.
  3259.         move.w    d4,CCR                    ;the status register.
  3260.         btst    #3,d0
  3261.         move.w    CCR,d4                    ;status updated.
  3262.  
  3263.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3264.         and.w    #$ff,d3                    ;n = 0!
  3265.  
  3266.         fetch_next_i
  3267.         cnop    0,128
  3268.  
  3269. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3270. ;        5C - LD E, H
  3271. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3272.  
  3273. z80_optcode_5C:    move.w    d2,d7
  3274.         subq.l    #1,a5                    ;less cycles.
  3275.         lsr.w    #8,d7
  3276.         move.b    d7,d0
  3277.  
  3278.         fetch_next_i
  3279.         cnop    0,128
  3280.  
  3281. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3282. ;        CB5C - BIT 3, H - [n = 0, h = 1, c = c, z = x]
  3283. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3284.  
  3285. z80_optc_CB5C:    subq.l    #2,a5                    ;less cycles.
  3286.         move.w    d4,CCR                    ;the status register.
  3287.         btst    #11,d2
  3288.         move.w    CCR,d4                    ;status updated.
  3289.  
  3290.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3291.         and.w    #$ff,d3                    ;n = 0!
  3292.  
  3293.         fetch_next_i
  3294.         cnop    0,128
  3295.  
  3296. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3297. ;        5D - LD E, L
  3298. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3299.  
  3300. z80_optcode_5D:    subq.l    #1,a5                    ;less cycles.
  3301.         move.b    d2,d0
  3302.  
  3303.         fetch_next_i
  3304.         cnop    0,128
  3305.  
  3306. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3307. ;        CB5D - BIT 3, L - [n = 0, h = 1, c = c, z = x]
  3308. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3309.  
  3310. z80_optc_CB5D:    subq.l    #2,a5                    ;less cycles.
  3311.         move.w    d4,CCR                    ;the status register.
  3312.         btst    #3,d2
  3313.         move.w    CCR,d4                    ;status updated.
  3314.  
  3315.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3316.         and.w    #$ff,d3                    ;n = 0!
  3317.  
  3318.         fetch_next_i
  3319.         cnop    0,128
  3320.  
  3321. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3322. ;        5E - LD E, (HL)
  3323. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3324.  
  3325. z80_optcode_5E:    subq.l    #2,a5                    ;less cycles.
  3326.  
  3327.         tst.w    d2                    ;rom read?
  3328.         blt.s    dread_d2_to_d0a                ;nope. from ram!
  3329.         move.b    (a3,d2.l),d0
  3330.  
  3331.         fetch_next_i
  3332.         cnop    0,4
  3333.  
  3334. dread_d2_to_d0a:move.b    (a2,d2.l),d0                ;ram read.
  3335.  
  3336.         fetch_next_i
  3337.         cnop    0,128
  3338.  
  3339. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3340. ;        CB5E - BIT 3, (HL) - [n = 0, h = 1, c = c, z = x]
  3341. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3342.  
  3343. z80_optc_CB5E:    subq.l    #4,a5
  3344.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3345.         and.w    #$ff,d3                    ;n = 0!
  3346.  
  3347.         tst.w    d2                    ;rom read?
  3348.         blt.s    read_d2d_to_d7a                ;nope. from ram!
  3349.  
  3350.         move.w    d4,CCR                    ;the status register.
  3351.         btst.b    #3,(a3,d2.l)
  3352.         move.w    CCR,d4                    ;status updated.
  3353.  
  3354.         fetch_next_i
  3355.         cnop    0,4
  3356.  
  3357. read_d2d_to_d7a:move.w    d4,CCR                    ;the status register.
  3358.         btst.b    #3,(a2,d2.l)                ;ram read.
  3359.         move.w    CCR,d4                    ;status updated.
  3360.  
  3361.         fetch_next_i
  3362.         cnop    0,128
  3363.  
  3364. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3365. ;        5F - LD E, A
  3366. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3367.  
  3368. z80_optcode_5F:    subq.l    #1,a5                    ;less cycles.
  3369.         move.b    d3,d0                    ;e = a.
  3370.  
  3371.         fetch_next_i
  3372.         cnop    0,128
  3373.  
  3374. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3375. ;        CB5F - BIT 3, A - [n = 0, h = 1, c = c, z = x]
  3376. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3377.  
  3378. z80_optc_CB5F:    subq.l    #2,a5                    ;less cycles.
  3379.         move.w    d4,CCR                    ;the status register.
  3380.         btst    #3,d3
  3381.         move.w    CCR,d4                    ;status updated.
  3382.  
  3383.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3384.         and.w    #$ff,d3                    ;n = 0!
  3385.  
  3386.         fetch_next_i
  3387.         cnop    0,128
  3388.  
  3389. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3390. ;        60 - LD H, B
  3391. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3392.  
  3393. z80_optcode_60:    move.b    d2,d7
  3394.         subq.l    #1,a5                    ;less cycles.
  3395.         move.w    d1,d2
  3396.         move.b    d7,d2
  3397.  
  3398.         fetch_next_i
  3399.         cnop    0,128
  3400.  
  3401. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3402. ;        CB60 - BIT 4, B - [n = 0, h = 1, c = c, z = x]
  3403. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3404.  
  3405. z80_optc_CB60:    subq.l    #2,a5                    ;less cycles.
  3406.         move.w    d4,CCR                    ;the status register.
  3407.         btst    #12,d1
  3408.         move.w    CCR,d4                    ;status updated.
  3409.  
  3410.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3411.         and.w    #$ff,d3                    ;n = 0!
  3412.  
  3413.         fetch_next_i
  3414.         cnop    0,128
  3415.  
  3416. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3417. ;        61 - LD H, C
  3418. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3419.  
  3420. z80_optcode_61:    ror.w    #8,d2
  3421.         subq.l    #1,a5                    ;less cycles.
  3422.         move.b    d1,d2
  3423.         rol.w    #8,d2
  3424.  
  3425.         fetch_next_i
  3426.         cnop    0,128
  3427.  
  3428. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3429. ;        CB61 - BIT 4, C - [n = 0, h = 1, c = c, z = x]
  3430. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3431.  
  3432. z80_optc_CB61:    subq.l    #2,a5                    ;less cycles.
  3433.         move.w    d4,CCR                    ;the status register.
  3434.         btst    #4,d1
  3435.         move.w    CCR,d4                    ;status updated.
  3436.  
  3437.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3438.         and.w    #$ff,d3                    ;n = 0!
  3439.  
  3440.         fetch_next_i
  3441.         cnop    0,128
  3442.  
  3443. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3444. ;        62 - LD H, D
  3445. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3446.  
  3447. z80_optcode_62:    move.b    d2,d7
  3448.         subq.l    #1,a5                    ;less cycles.
  3449.         move.w    d0,d2
  3450.         move.b    d7,d2
  3451.  
  3452.         fetch_next_i
  3453.         cnop    0,128
  3454.  
  3455. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3456. ;        CB62 - BIT 4, D - [n = 0, h = 1, c = c, z = x]
  3457. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3458.  
  3459. z80_optc_CB62:    subq.l    #2,a5                    ;less cycles.
  3460.         move.w    d4,CCR                    ;the status register.
  3461.         btst    #12,d0
  3462.         move.w    CCR,d4                    ;status updated.
  3463.  
  3464.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3465.         and.w    #$ff,d3                    ;n = 0!
  3466.  
  3467.         fetch_next_i
  3468.         cnop    0,128
  3469.  
  3470. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3471. ;        63 - LD H, E
  3472. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3473.  
  3474. z80_optcode_63:    ror.w    #8,d2                    ;h down.
  3475.         subq.l    #1,a5                    ;less cycles.
  3476.         move.b    d0,d2                    ;h = e.
  3477.         rol.w    #8,d2                    ;h back to up.
  3478.  
  3479.         fetch_next_i
  3480.         cnop    0,128
  3481.  
  3482. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3483. ;        CB63 - BIT 4, E - [n = 0, h = 1, c = c, z = x]
  3484. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3485.  
  3486. z80_optc_CB63:    subq.l    #2,a5                    ;less cycles.
  3487.         move.w    d4,CCR                    ;the status register.
  3488.         btst    #4,d0
  3489.         move.w    CCR,d4                    ;status updated.
  3490.  
  3491.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3492.         and.w    #$ff,d3                    ;n = 0!
  3493.  
  3494.         fetch_next_i
  3495.         cnop    0,128
  3496.  
  3497. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3498. ;        64 - LD H, H
  3499. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3500.  
  3501. z80_optcode_64:    subq.l    #1,a5                    ;less cycles.
  3502.  
  3503.         fetch_next_i
  3504.         cnop    0,128
  3505.  
  3506. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3507. ;        CB64 - BIT 4, H - [n = 0, h = 1, c = c, z = x]
  3508. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3509.  
  3510. z80_optc_CB64:    subq.l    #2,a5                    ;less cycles.
  3511.         move.w    d4,CCR                    ;the status register.
  3512.         btst    #12,d2
  3513.         move.w    CCR,d4                    ;status updated.
  3514.  
  3515.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3516.         and.w    #$ff,d3                    ;n = 0!
  3517.  
  3518.         fetch_next_i
  3519.         cnop    0,128
  3520.  
  3521. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3522. ;        65 - LD H, L
  3523. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3524.  
  3525. z80_optcode_65:    move.b    d2,d7
  3526.         subq.l    #1,a5                    ;less cycles.
  3527.         lsl.w    #8,d2
  3528.         move.b    d7,d2
  3529.  
  3530.         fetch_next_i
  3531.         cnop    0,128
  3532.  
  3533. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3534. ;        CB65 - BIT 4, L - [n = 0, h = 1, c = c, z = x]
  3535. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3536.  
  3537. z80_optc_CB65:    subq.l    #2,a5                    ;less cycles.
  3538.         move.w    d4,CCR                    ;the status register.
  3539.         btst    #4,d2
  3540.         move.w    CCR,d4                    ;status updated.
  3541.  
  3542.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3543.         and.w    #$ff,d3                    ;n = 0!
  3544.  
  3545.         fetch_next_i
  3546.         cnop    0,128
  3547.  
  3548. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3549. ;        66 - LD H, (HL)
  3550. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3551.  
  3552. z80_optcode_66:    move.w    d2,d7                    ;d7 = h.B, l.B.
  3553.         subq.l    #2,a5                    ;less cycles.
  3554.         ror.w    #8,d2                    ;h down.
  3555.  
  3556.         tst.w    d7
  3557.         blt.s    read_d7_to_d2a                ;nope. from ram!
  3558.         move.b    (a3,d7.l),d2
  3559.         rol.w    #8,d2                    ;h back to up.
  3560.  
  3561.         fetch_next_i
  3562.         cnop    0,4
  3563.  
  3564. read_d7_to_d2a:    move.b    (a2,d7.l),d2                ;ram read.
  3565.         rol.w    #8,d2                    ;h back to up.
  3566.  
  3567.         fetch_next_i
  3568.         cnop    0,128
  3569.  
  3570. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3571. ;        CB66 - BIT 4, (HL) - [n = 0, h = 1, c = c, z = x]
  3572. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3573.  
  3574. z80_optc_CB66:    subq.l    #4,a5
  3575.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3576.         and.w    #$ff,d3                    ;n = 0!
  3577.  
  3578.         tst.w    d2                    ;rom read?
  3579.         blt.s    read_d2e_to_d7a                ;nope. from ram!
  3580.  
  3581.         move.w    d4,CCR                    ;the status register.
  3582.         btst.b    #4,(a3,d2.l)
  3583.         move.w    CCR,d4                    ;status updated.
  3584.  
  3585.         fetch_next_i
  3586.         cnop    0,4
  3587.  
  3588. read_d2e_to_d7a:move.w    d4,CCR                    ;the status register.
  3589.         btst.b    #4,(a2,d2.l)                ;ram read.
  3590.         move.w    CCR,d4                    ;status updated.
  3591.  
  3592.         fetch_next_i
  3593.         cnop    0,128
  3594.  
  3595. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3596. ;        67 - LD H, A
  3597. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3598.  
  3599. z80_optcode_67:    ror.w    #8,d2
  3600.         subq.l    #1,a5                    ;less cycles.
  3601.         move.b    d3,d2
  3602.         rol.w    #8,d2
  3603.  
  3604.         fetch_next_i
  3605.         cnop    0,128
  3606.  
  3607. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3608. ;        CB67 - BIT 4, A - [n = 0, h = 1, c = c, z = x]
  3609. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3610.  
  3611. z80_optc_CB67:    subq.l    #2,a5                    ;less cycles.
  3612.         move.w    d4,CCR                    ;the status register.
  3613.         btst    #4,d3
  3614.         move.w    CCR,d4                    ;status updated.
  3615.  
  3616.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3617.         and.w    #$ff,d3                    ;n = 0!
  3618.  
  3619.         fetch_next_i
  3620.         cnop    0,128
  3621.  
  3622. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3623. ;        68 - LD L, B
  3624. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3625.  
  3626. z80_optcode_68:    move.w    d1,d7
  3627.         subq.l    #1,a5                    ;less cycles.
  3628.         lsr.w    #8,d7
  3629.         move.b    d7,d2
  3630.  
  3631.         fetch_next_i
  3632.         cnop    0,128
  3633.  
  3634. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3635. ;        CB68 - BIT 5, B - [n = 0, h = 1, c = c, z = x]
  3636. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3637.  
  3638. z80_optc_CB68:    subq.l    #2,a5                    ;less cycles.
  3639.         move.w    d4,CCR                    ;the status register.
  3640.         btst    #13,d1
  3641.         move.w    CCR,d4                    ;status updated.
  3642.  
  3643.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3644.         and.w    #$ff,d3                    ;n = 0!
  3645.  
  3646.         fetch_next_i
  3647.         cnop    0,128
  3648.  
  3649. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3650. ;        69 - LD L, C
  3651. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3652.  
  3653. z80_optcode_69:    subq.l    #1,a5                    ;less cycles.
  3654.         move.b    d1,d2
  3655.  
  3656.         fetch_next_i
  3657.         cnop    0,128
  3658.  
  3659. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3660. ;        CB69 - BIT 5, C - [n = 0, h = 1, c = c, z = x]
  3661. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3662.  
  3663. z80_optc_CB69:    subq.l    #2,a5                    ;less cycles.
  3664.         move.w    d4,CCR                    ;the status register.
  3665.         btst    #5,d1
  3666.         move.w    CCR,d4                    ;status updated.
  3667.  
  3668.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3669.         and.w    #$ff,d3                    ;n = 0!
  3670.  
  3671.         fetch_next_i
  3672.         cnop    0,128
  3673.  
  3674. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3675. ;        6A - LD L, D
  3676. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3677.  
  3678. z80_optcode_6A:    move.w    d0,d7
  3679.         subq.l    #1,a5                    ;less cycles.
  3680.         lsr.w    #8,d7
  3681.         move.b    d7,d2
  3682.  
  3683.         fetch_next_i
  3684.         cnop    0,128
  3685.  
  3686. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3687. ;        CB6A - BIT 5, D - [n = 0, h = 1, c = c, z = x]
  3688. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3689.  
  3690. z80_optc_CB6A:    subq.l    #2,a5                    ;less cycles.
  3691.         move.w    d4,CCR                    ;the status register.
  3692.         btst    #13,d0
  3693.         move.w    CCR,d4                    ;status updated.
  3694.  
  3695.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3696.         and.w    #$ff,d3                    ;n = 0!
  3697.  
  3698.         fetch_next_i
  3699.         cnop    0,128
  3700.  
  3701. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3702. ;        6B - LD L, E
  3703. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3704.  
  3705. z80_optcode_6B:    subq.l    #1,a5                    ;less cycles.
  3706.         move.b    d0,d2
  3707.  
  3708.         fetch_next_i
  3709.         cnop    0,128
  3710.  
  3711. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3712. ;        CB6B - BIT 5, E - [n = 0, h = 1, c = c, z = x]
  3713. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3714.  
  3715. z80_optc_CB6B:    subq.l    #2,a5                    ;less cycles.
  3716.         move.w    d4,CCR                    ;the status register.
  3717.         btst    #5,d0
  3718.         move.w    CCR,d4                    ;status updated.
  3719.  
  3720.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3721.         and.w    #$ff,d3                    ;n = 0!
  3722.  
  3723.         fetch_next_i
  3724.         cnop    0,128
  3725.  
  3726. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3727. ;        6C - LD L, H
  3728. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3729.  
  3730. z80_optcode_6C:    move.w    d2,d7
  3731.         subq.l    #1,a5                    ;less cycles.
  3732.         lsr.w    #8,d7
  3733.         move.b    d7,d2
  3734.  
  3735.         fetch_next_i
  3736.         cnop    0,128
  3737.  
  3738. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3739. ;        CB6C - BIT 5, H - [n = 0, h = 1, c = c, z = x]
  3740. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3741.  
  3742. z80_optc_CB6C:    subq.l    #2,a5                    ;less cycles.
  3743.         move.w    d4,CCR                    ;the status register.
  3744.         btst    #13,d2
  3745.         move.w    CCR,d4                    ;status updated.
  3746.  
  3747.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3748.         and.w    #$ff,d3                    ;n = 0!
  3749.  
  3750.         fetch_next_i
  3751.         cnop    0,128
  3752.  
  3753. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3754. ;        6D - LD L, L
  3755. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3756.  
  3757. z80_optcode_6D:    subq.l    #1,a5                    ;less cycles.
  3758.  
  3759.         fetch_next_i
  3760.         cnop    0,128
  3761.  
  3762. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3763. ;        CB6D - BIT 5, L - [n = 0, h = 1, c = c, z = x]
  3764. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3765.  
  3766. z80_optc_CB6D:    subq.l    #2,a5                    ;less cycles.
  3767.         move.w    d4,CCR                    ;the status register.
  3768.         btst    #5,d2
  3769.         move.w    CCR,d4                    ;status updated.
  3770.  
  3771.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3772.         and.w    #$ff,d3                    ;n = 0!
  3773.  
  3774.         fetch_next_i
  3775.         cnop    0,128
  3776.  
  3777. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3778. ;        6E - LD L, (HL)
  3779. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3780.  
  3781. z80_optcode_6E:    subq.l    #2,a5                    ;less cycles.
  3782.  
  3783.         tst.w    d2                    ;rom read?
  3784.         blt.s    read_d2_to_d2a                ;nope. from ram!
  3785.         move.b    (a3,d2.l),d2
  3786.  
  3787.         fetch_next_i
  3788.         cnop    0,4
  3789.  
  3790. read_d2_to_d2a:    move.b    (a2,d2.l),d2                ;ram read.
  3791.  
  3792.         fetch_next_i
  3793.         cnop    0,128
  3794.  
  3795. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3796. ;        CB6E - BIT 5, (HL) - [n = 0, h = 1, c = c, z = x]
  3797. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3798.  
  3799. z80_optc_CB6E:    subq.l    #4,a5
  3800.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3801.         and.w    #$ff,d3                    ;n = 0!
  3802.  
  3803.         tst.w    d2                    ;rom read?
  3804.         blt.s    read_d2f_to_d7a                ;nope. from ram!
  3805.  
  3806.         move.w    d4,CCR                    ;the status register.
  3807.         btst.b    #5,(a3,d2.l)
  3808.         move.w    CCR,d4                    ;status updated.
  3809.  
  3810.         fetch_next_i
  3811.         cnop    0,4
  3812.  
  3813. read_d2f_to_d7a:move.w    d4,CCR                    ;the status register.
  3814.         btst.b    #5,(a2,d2.l)                ;ram read.
  3815.         move.w    CCR,d4                    ;status updated.
  3816.  
  3817.         fetch_next_i
  3818.         cnop    0,128
  3819.  
  3820. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3821. ;        6F - LD L, A
  3822. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3823.  
  3824. z80_optcode_6F:    subq.l    #1,a5                    ;less cycles.
  3825.         move.b    d3,d2                    ;l = a.
  3826.  
  3827.         fetch_next_i
  3828.         cnop    0,128
  3829.  
  3830. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3831. ;        CB6F - BIT 5, A - [n = 0, h = 1, c = c, z = x]
  3832. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3833.  
  3834. z80_optc_CB6F:    subq.l    #2,a5                    ;less cycles.
  3835.         move.w    d4,CCR                    ;the status register.
  3836.         btst    #5,d3
  3837.         move.w    CCR,d4                    ;status updated.
  3838.  
  3839.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3840.         and.w    #$ff,d3                    ;n = 0!
  3841.  
  3842.         fetch_next_i
  3843.         cnop    0,128
  3844.  
  3845. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3846. ;        70 - LD (HL), B
  3847. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3848.  
  3849. z80_optcode_70:    move.w    d1,d6
  3850.         move.w    d2,d7
  3851.         lsr.w    #8,d6
  3852.         move.l    gb_mem_jumps,a6
  3853.         subq.l    #2,a5
  3854.         jsr    ([a6,d2.l*4])                ;memory write.
  3855.  
  3856.         fetch_next_i
  3857.         cnop    0,128
  3858.  
  3859. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3860. ;        CB70 - BIT 6, B - [n = 0, h = 1, c = c, z = x]
  3861. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3862.  
  3863. z80_optc_CB70:    subq.l    #2,a5                    ;less cycles.
  3864.         move.w    d4,CCR                    ;the status register.
  3865.         btst    #14,d1
  3866.         move.w    CCR,d4                    ;status updated.
  3867.  
  3868.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3869.         and.w    #$ff,d3                    ;n = 0!
  3870.  
  3871.         fetch_next_i
  3872.         cnop    0,128
  3873.  
  3874. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3875. ;        71 - LD (HL), C
  3876. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3877.  
  3878. z80_optcode_71:    move.b    d1,d6
  3879.         move.w    d2,d7
  3880.         move.l    gb_mem_jumps,a6
  3881.         subq.l    #2,a5
  3882.         jsr    ([a6,d2.l*4])                ;memory write.
  3883.  
  3884.         fetch_next_i
  3885.         cnop    0,128
  3886.  
  3887. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3888. ;        CB71 - BIT 6, C - [n = 0, h = 1, c = c, z = x]
  3889. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3890.  
  3891. z80_optc_CB71:    subq.l    #2,a5                    ;less cycles.
  3892.         move.w    d4,CCR                    ;the status register.
  3893.         btst    #6,d1
  3894.         move.w    CCR,d4                    ;status updated.
  3895.  
  3896.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3897.         and.w    #$ff,d3                    ;n = 0!
  3898.  
  3899.         fetch_next_i
  3900.         cnop    0,128
  3901.  
  3902. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3903. ;        72 - LD (HL), D
  3904. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3905.  
  3906. z80_optcode_72:    move.w    d0,d6
  3907.         move.w    d2,d7
  3908.         lsr.w    #8,d6
  3909.         move.l    gb_mem_jumps,a6
  3910.         subq.l    #2,a5
  3911.         jsr    ([a6,d2.l*4])                ;memory write.
  3912.  
  3913.         fetch_next_i
  3914.         cnop    0,128
  3915.  
  3916. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3917. ;        CB72 - BIT 6, D - [n = 0, h = 1, c = c, z = x]
  3918. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3919.  
  3920. z80_optc_CB72:    subq.l    #2,a5                    ;less cycles.
  3921.         move.w    d4,CCR                    ;the status register.
  3922.         btst    #14,d0
  3923.         move.w    CCR,d4                    ;status updated.
  3924.  
  3925.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3926.         and.w    #$ff,d3                    ;n = 0!
  3927.  
  3928.         fetch_next_i
  3929.         cnop    0,128
  3930.  
  3931. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3932. ;        73 - LD (HL), E
  3933. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3934.  
  3935. z80_optcode_73:    move.w    d2,d7
  3936.         move.b    d0,d6
  3937.         move.l    gb_mem_jumps,a6
  3938.         subq.l    #2,a5
  3939.         jsr    ([a6,d2.l*4])                ;memory write.
  3940.  
  3941.         fetch_next_i
  3942.         cnop    0,128
  3943.  
  3944. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3945. ;        CB73 - BIT 6, E - [n = 0, h = 1, c = c, z = x]
  3946. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3947.  
  3948. z80_optc_CB73:    subq.l    #2,a5                    ;less cycles.
  3949.         move.w    d4,CCR                    ;the status register.
  3950.         btst    #6,d0
  3951.         move.w    CCR,d4                    ;status updated.
  3952.  
  3953.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3954.         and.w    #$ff,d3                    ;n = 0!
  3955.  
  3956.         fetch_next_i
  3957.         cnop    0,128
  3958.  
  3959. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3960. ;        74 - LD (HL), H
  3961. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3962.  
  3963. z80_optcode_74:    move.w    d2,d6
  3964.         move.w    d2,d7
  3965.         lsr.w    #8,d6
  3966.         move.l    gb_mem_jumps,a6
  3967.         subq.l    #2,a5
  3968.         jsr    ([a6,d2.l*4])                ;memory write.
  3969.  
  3970.         fetch_next_i
  3971.         cnop    0,128
  3972.  
  3973. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3974. ;        CB74 - BIT 6, H - [n = 0, h = 1, c = c, z = x]
  3975. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3976.  
  3977. z80_optc_CB74:    subq.l    #2,a5                    ;less cycles.
  3978.         move.w    d4,CCR                    ;the status register.
  3979.         btst    #14,d2
  3980.         move.w    CCR,d4                    ;status updated.
  3981.  
  3982.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  3983.         and.w    #$ff,d3                    ;n = 0!
  3984.  
  3985.         fetch_next_i
  3986.         cnop    0,128
  3987.  
  3988. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3989. ;        75 - LD (HL), L
  3990. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  3991.  
  3992. z80_optcode_75:    move.w    d2,d7
  3993.         move.b    d2,d6
  3994.         move.l    gb_mem_jumps,a6
  3995.         subq.l    #2,a5
  3996.         jsr    ([a6,d2.l*4])                ;memory write.
  3997.  
  3998.         fetch_next_i
  3999.         cnop    0,128
  4000.  
  4001. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4002. ;        CB75 - BIT 6, L - [n = 0, h = 1, c = c, z = x]
  4003. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4004.  
  4005. z80_optc_CB75:    subq.l    #2,a5                    ;less cycles.
  4006.         move.w    d4,CCR                    ;the status register.
  4007.         btst    #6,d2
  4008.         move.w    CCR,d4                    ;status updated.
  4009.  
  4010.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  4011.         and.w    #$ff,d3                    ;n = 0!
  4012.  
  4013.         fetch_next_i
  4014.         cnop    0,128
  4015.  
  4016. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4017. ;        76 - HALT
  4018. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4019.  
  4020. z80_optcode_76:    subq.l    #1,a5
  4021.         tst.b    i_flag
  4022.         bne.s    z80_optcode_76_skip
  4023.  
  4024.         move.b    #2,z80_halt                ;z80 stopped!
  4025.         rts
  4026.  
  4027.         cnop    0,4
  4028. z80_optcode_76_skip:
  4029.         move.l    a5,d6                    ;test cycles left.
  4030.         ble.s    f_xit_xit
  4031.  
  4032.         IFGT    GAMEBOY_DEBUG
  4033.         jmp    debug_output
  4034.         ELSE
  4035.         move.b    (a0),d7
  4036.         lsl.w    #8,d7                    ;d0 = d0*256.
  4037.         jmp    (a1,d7.l)                ;jump and emulate.
  4038.         ENDIF
  4039.  
  4040.         cnop    0,4
  4041. f_xit_xit:    rts
  4042.  
  4043.         cnop    0,128
  4044.  
  4045. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4046. ;        CB76 - BIT 6, (HL) - [n = 0, h = 1, c = c, z = x]
  4047. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4048.  
  4049. z80_optc_CB76:    subq.l    #4,a5
  4050.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  4051.         and.w    #$ff,d3                    ;n = 0!
  4052.  
  4053.         tst.w    d2                    ;rom read?
  4054.         blt.s    read_d2g_to_d7a                ;nope. from ram!
  4055.  
  4056.         move.w    d4,CCR                    ;the status register.
  4057.         btst.b    #6,(a3,d2.l)
  4058.         move.w    CCR,d4                    ;status updated.
  4059.  
  4060.         fetch_next_i
  4061.         cnop    0,4
  4062.  
  4063. read_d2g_to_d7a:move.w    d4,CCR                    ;the status register.
  4064.         btst.b    #6,(a2,d2.l)                ;ram read.
  4065.         move.w    CCR,d4                    ;status updated.
  4066.  
  4067.         fetch_next_i
  4068.         cnop    0,128
  4069.  
  4070. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4071. ;        77 - LD (HL), A
  4072. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4073.  
  4074. z80_optcode_77:    move.w    d2,d7
  4075.         move.b    d3,d6
  4076.         move.l    gb_mem_jumps,a6
  4077.         subq.l    #2,a5
  4078.         jsr    ([a6,d2.l*4])                ;memory write.
  4079.  
  4080.         fetch_next_i
  4081.         cnop    0,128
  4082.  
  4083. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4084. ;        CB77 - BIT 6, A - [n = 0, h = 1, c = c, z = x]
  4085. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4086.  
  4087. z80_optc_CB77:    subq.l    #2,a5                    ;less cycles.
  4088.         move.w    d4,CCR                    ;the status register.
  4089.         btst    #6,d3
  4090.         move.w    CCR,d4                    ;status updated.
  4091.  
  4092.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  4093.         and.w    #$ff,d3                    ;n = 0!
  4094.  
  4095.         fetch_next_i
  4096.         cnop    0,128
  4097.  
  4098. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4099. ;        78 - LD A, B
  4100. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4101.  
  4102. z80_optcode_78:    move.w    d1,d7
  4103.         subq.l    #1,a5                    ;less cycles.
  4104.         lsr.w    #8,d7
  4105.         move.b    d7,d3
  4106.  
  4107.         fetch_next_i
  4108.         cnop    0,128
  4109.  
  4110. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4111. ;        CB78 - BIT 7, B - [n = 0, h = 1, c = c, z = x]
  4112. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4113.  
  4114. z80_optc_CB78:    subq.l    #2,a5                    ;less cycles.
  4115.         move.w    d4,CCR                    ;the status register.
  4116.         btst    #15,d1
  4117.         move.w    CCR,d4                    ;status updated.
  4118.  
  4119.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  4120.         and.w    #$ff,d3                    ;n = 0!
  4121.  
  4122.         fetch_next_i
  4123.         cnop    0,128
  4124.  
  4125. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4126. ;        79 - LD A, C
  4127. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4128.  
  4129. z80_optcode_79:    subq.l    #1,a5                    ;less cycles.
  4130.         move.b    d1,d3
  4131.  
  4132.         fetch_next_i
  4133.         cnop    0,128
  4134.  
  4135. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4136. ;        CB79 - BIT 7, C - [n = 0, h = 1, c = c, z = x]
  4137. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4138.  
  4139. z80_optc_CB79:    subq.l    #2,a5                    ;less cycles.
  4140.         move.w    d4,CCR                    ;the status register.
  4141.         btst    #7,d1
  4142.         move.w    CCR,d4                    ;status updated.
  4143.  
  4144.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  4145.         and.w    #$ff,d3                    ;n = 0!
  4146.  
  4147.         fetch_next_i
  4148.         cnop    0,128
  4149.  
  4150. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4151. ;        7A - LD A, D
  4152. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4153.  
  4154. z80_optcode_7A:    move.w    d0,d7
  4155.         subq.l    #1,a5                    ;less cycles.
  4156.         lsr.w    #8,d7
  4157.         move.b    d7,d3
  4158.  
  4159.         fetch_next_i
  4160.         cnop    0,128
  4161.  
  4162. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4163. ;        CB7A - BIT 7, D - [n = 0, h = 1, c = c, z = x]
  4164. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4165.  
  4166. z80_optc_CB7A:    subq.l    #2,a5                    ;less cycles.
  4167.         move.w    d4,CCR                    ;the status register.
  4168.         btst    #15,d0
  4169.         move.w    CCR,d4                    ;status updated.
  4170.  
  4171.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  4172.         and.w    #$ff,d3                    ;n = 0!
  4173.  
  4174.         fetch_next_i
  4175.         cnop    0,128
  4176.  
  4177. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4178. ;        7B - LD A, E
  4179. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4180.  
  4181. z80_optcode_7B:    subq.l    #1,a5                    ;less cycles.
  4182.         move.b    d0,d3
  4183.  
  4184.         fetch_next_i
  4185.         cnop    0,128
  4186.  
  4187. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4188. ;        CB7B - BIT 7, E - [n = 0, h = 1, c = c, z = x]
  4189. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4190.  
  4191. z80_optc_CB7B:    subq.l    #2,a5                    ;less cycles.
  4192.         move.w    d4,CCR                    ;the status register.
  4193.         btst    #7,d0
  4194.         move.w    CCR,d4                    ;status updated.
  4195.  
  4196.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  4197.         and.w    #$ff,d3                    ;n = 0!
  4198.  
  4199.         fetch_next_i
  4200.         cnop    0,128
  4201.  
  4202. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4203. ;        7C - LD A, H
  4204. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4205.  
  4206. z80_optcode_7C:    move.w    d2,d7
  4207.         subq.l    #1,a5                    ;less cycles.
  4208.         lsr.w    #8,d7
  4209.         move.b    d7,d3
  4210.  
  4211.         fetch_next_i
  4212.         cnop    0,128
  4213.  
  4214. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4215. ;        CB7C - BIT 7, H - [n = 0, h = 1, c = c, z = x]
  4216. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4217.  
  4218. z80_optc_CB7C:    subq.l    #2,a5                    ;less cycles.
  4219.         move.w    d4,CCR                    ;the status register.
  4220.         btst    #15,d2
  4221.         move.w    CCR,d4                    ;status updated.
  4222.  
  4223.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  4224.         and.w    #$ff,d3                    ;n = 0!
  4225.  
  4226.         fetch_next_i
  4227.         cnop    0,128
  4228.  
  4229. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4230. ;        7D - LD A, L
  4231. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4232.  
  4233. z80_optcode_7D:    subq.l    #1,a5                    ;less cycles.
  4234.         move.b    d2,d3
  4235.  
  4236.         fetch_next_i
  4237.         cnop    0,128
  4238.  
  4239. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4240. ;        CB7D - BIT 7, L - [n = 0, h = 1, c = c, z = x]
  4241. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4242.  
  4243. z80_optc_CB7D:    subq.l    #2,a5                    ;less cycles.
  4244.         move.w    d4,CCR                    ;the status register.
  4245.         btst    #7,d2
  4246.         move.w    CCR,d4                    ;status updated.
  4247.  
  4248.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  4249.         and.w    #$ff,d3                    ;n = 0!
  4250.  
  4251.         fetch_next_i
  4252.         cnop    0,128
  4253.  
  4254. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4255. ;        7E - LD A, (HL)
  4256. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4257.  
  4258. z80_optcode_7E:    subq.l    #2,a5                    ;less cycles.
  4259.  
  4260.         tst.w    d2                    ;rom read?
  4261.         blt.s    read_d2_to_d3a3                ;nope. from ram!
  4262.  
  4263.         move.b    (a3,d2.l),d3
  4264.  
  4265.         fetch_next_i
  4266.         cnop    0,4
  4267.  
  4268. read_d2_to_d3a3:move.b    (a2,d2.l),d3                ;ram read.
  4269.  
  4270.         fetch_next_i
  4271.         cnop    0,128
  4272.  
  4273. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4274. ;        CB7E - BIT 7, (HL) - [n = 0, h = 1, c = c, z = x]
  4275. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4276.  
  4277. z80_optc_CB7E:    subq.l    #4,a5
  4278.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  4279.         and.w    #$ff,d3                    ;n = 0!
  4280.  
  4281.         tst.w    d2                    ;rom read?
  4282.         blt.s    read_d2h_to_d7a                ;nope. from ram!
  4283.  
  4284.         move.w    d4,CCR                    ;the status register.
  4285.         btst.b    #7,(a3,d2.l)
  4286.         move.w    CCR,d4                    ;status updated.
  4287.  
  4288.         fetch_next_i
  4289.         cnop    0,4
  4290.  
  4291. read_d2h_to_d7a:move.w    d4,CCR                    ;the status register.
  4292.         btst.b    #7,(a2,d2.l)                ;ram read.
  4293.         move.w    CCR,d4                    ;status updated.
  4294.  
  4295.         fetch_next_i
  4296.         cnop    0,128
  4297.  
  4298. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4299. ;        7F - LD A, A
  4300. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4301.  
  4302. z80_optcode_7F:    subq.l    #1,a5                    ;less cycles.
  4303.  
  4304.         fetch_next_i
  4305.         cnop    0,128
  4306.  
  4307. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4308. ;        CB7F - BIT 7, A - [n = 0, h = 1, c = c, z = x]
  4309. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4310.  
  4311. z80_optc_CB7F:    subq.l    #2,a5                    ;less cycles.
  4312.         move.w    d4,CCR                    ;the status register.
  4313.         btst    #7,d3
  4314.         move.w    CCR,d4                    ;status updated.
  4315.  
  4316.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  4317.         and.w    #$ff,d3                    ;n = 0!
  4318.  
  4319.         fetch_next_i
  4320.         cnop    0,128
  4321.  
  4322. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4323. ;        80 - ADD B - [n = 0, h = x, c = x, z = x]
  4324. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4325.  
  4326. z80_optcode_80:    ror.w    #8,d1
  4327.         move.b    d3,h_other_I
  4328.         subq.l    #1,a5
  4329.         move.b    d1,h_other_II
  4330.  
  4331.         add.b    d1,d3
  4332.         move.w    CCR,d4
  4333.         rol.w    #8,d1
  4334.  
  4335.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  4336.         and.w    #$ff,d3                    ;n = 0!
  4337.  
  4338.         fetch_next_i
  4339.         cnop    0,128
  4340.  
  4341. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4342. ;        CB80 - RES 0, B
  4343. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4344.  
  4345. z80_optc_CB80:    subq.l    #2,a5                    ;less cycles.
  4346.         and.w    #%1111111011111111,d1
  4347.         fetch_next_i
  4348.         cnop    0,128
  4349.  
  4350. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4351. ;        81 - ADD C - [n = 0, h = x, c = x, z = x]
  4352. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4353.  
  4354. z80_optcode_81:    move.b    d1,h_other_II
  4355.         subq.l    #1,a5                    ;less cycles.
  4356.         move.b    d3,h_other_I
  4357.  
  4358.         add.b    d1,d3                    ;a = a + c.
  4359.         move.w    CCR,d4                    ;status updated.
  4360.  
  4361.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  4362.         and.w    #$ff,d3                    ;n = 0!
  4363.  
  4364.         fetch_next_i
  4365.         cnop    0,128
  4366.  
  4367. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4368. ;        CB81 - RES 0, C
  4369. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4370.  
  4371. z80_optc_CB81:    subq.l    #2,a5                    ;less cycles.
  4372.         and.b    #%11111110,d1
  4373.         fetch_next_i
  4374.         cnop    0,128
  4375.  
  4376. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4377. ;        82 - ADD D - [n = 0, h = x, c = x, z = x]
  4378. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4379.  
  4380. z80_optcode_82:    ror.w    #8,d0                    ;d down.
  4381.         move.b    d3,h_other_I
  4382.         subq.l    #1,a5                    ;less cycles.
  4383.         move.b    d0,h_other_II
  4384.  
  4385.         add.b    d0,d3                    ;a = a + d.
  4386.         move.w    CCR,d4                    ;status updated.
  4387.         rol.w    #8,d0                    ;d back to up.
  4388.  
  4389.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  4390.         and.w    #$ff,d3                    ;n = 0!
  4391.  
  4392.         fetch_next_i
  4393.         cnop    0,128
  4394.  
  4395. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4396. ;        CB82 - RES 0, D
  4397. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4398.  
  4399. z80_optc_CB82:    subq.l    #2,a5                    ;less cycles.
  4400.         and.w    #%1111111011111111,d0
  4401.         fetch_next_i
  4402.         cnop    0,128
  4403.  
  4404. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4405. ;        83 - ADD E - [n = 0, h = x, c = x, z = x]
  4406. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4407.  
  4408. z80_optcode_83:    move.b    d0,h_other_II
  4409.         subq.l    #1,a5                    ;less cycles.
  4410.         move.b    d3,h_other_I
  4411.  
  4412.         add.b    d0,d3                    ;a = a + e.
  4413.         move.w    CCR,d4                    ;status updated.
  4414.  
  4415.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  4416.         and.w    #$ff,d3                    ;n = 0!
  4417.  
  4418.         fetch_next_i
  4419.         cnop    0,128
  4420.  
  4421. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4422. ;        CB83 - RES 0, E
  4423. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4424.  
  4425. z80_optc_CB83:    subq.l    #2,a5                    ;less cycles.
  4426.         and.b    #%11111110,d0
  4427.         fetch_next_i
  4428.         cnop    0,128
  4429.  
  4430. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4431. ;        84 - ADD H - [n = 0, h = x, c = x, z = x]
  4432. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4433.  
  4434. z80_optcode_84:    ror.w    #8,d2                    ;h down.
  4435.         move.b    d3,h_other_I
  4436.         subq.l    #1,a5                    ;less cycles.
  4437.         move.b    d2,h_other_II
  4438.  
  4439.         add.b    d2,d3                    ;a = a + h.
  4440.         move.w    CCR,d4                    ;status updated.
  4441.         rol.w    #8,d2                    ;h back to up.
  4442.  
  4443.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  4444.         and.w    #$ff,d3                    ;n = 0!
  4445.  
  4446.         fetch_next_i
  4447.         cnop    0,128
  4448.  
  4449. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4450. ;        CB84 - RES 0, H
  4451. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4452.  
  4453. z80_optc_CB84:    subq.l    #2,a5                    ;less cycles.
  4454.         and.w    #%1111111011111111,d2
  4455.         fetch_next_i
  4456.         cnop    0,128
  4457.  
  4458. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4459. ;        85 - ADD L - [n = 0, h = x, c = x, z = x]
  4460. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4461.  
  4462. z80_optcode_85:    move.b    d2,h_other_II
  4463.         subq.l    #1,a5                    ;less cycles.
  4464.         move.b    d3,h_other_I
  4465.  
  4466.         add.b    d2,d3                    ;a = a + l.
  4467.         move.w    CCR,d4                    ;status updated.
  4468.  
  4469.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  4470.         and.w    #$ff,d3                    ;n = 0!
  4471.  
  4472.         fetch_next_i
  4473.         cnop    0,128
  4474.  
  4475. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4476. ;        CB85 - RES 0, L
  4477. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4478.  
  4479. z80_optc_CB85:    subq.l    #2,a5                    ;less cycles.
  4480.         and.b    #%11111110,d2
  4481.         fetch_next_i
  4482.         cnop    0,128
  4483.  
  4484. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4485. ;        86 - ADD (HL) - [n = 0, h = x, c = x, z = x]
  4486. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4487.  
  4488. z80_optcode_86:    
  4489.         READ_D2_TO_D6
  4490.  
  4491.         move.b    d3,h_other_I
  4492.         subq.l    #2,a5                    ;less cycles.
  4493.         move.b    d6,h_other_II
  4494.  
  4495.         add.b    d6,d3                    ;a = a + (hl).
  4496.         move.w    CCR,d4                    ;status updated.
  4497.  
  4498.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  4499.         and.w    #$ff,d3                    ;n = 0!
  4500.  
  4501.         fetch_next_i
  4502.         cnop    0,128
  4503.  
  4504. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4505. ;        CB86 - RES 0, (HL)
  4506. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4507.  
  4508. z80_optc_CB86:    subq.l    #4,a5
  4509.         READ_D2_TO_D6
  4510.         and.b    #%11111110,d6
  4511.         move.w    d2,d7                    ;d7 = a (hl) - write.
  4512.  
  4513.         move.l    gb_mem_jumps,a6
  4514.         jsr    ([a6,d2.l*4])                ;memory write.
  4515.  
  4516.         fetch_next_i
  4517.         cnop    0,128
  4518.  
  4519. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4520. ;        87 - ADD A - [n = 0, h = x, c = x, z = x]
  4521. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4522.  
  4523. z80_optcode_87:    move.b    d3,h_other_II
  4524.         subq.l    #1,a5                    ;less cycles.
  4525.         move.b    d3,h_other_I
  4526.  
  4527.         add.b    d3,d3                    ;a = a + a.
  4528.         move.w    CCR,d4                    ;status updated.
  4529.  
  4530.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  4531.         and.w    #$ff,d3                    ;n = 0!
  4532.  
  4533.         fetch_next_i
  4534.         cnop    0,128
  4535.  
  4536. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4537. ;        CB87 - RES 0, A
  4538. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4539.  
  4540. z80_optc_CB87:    subq.l    #2,a5                    ;less cycles.
  4541.         and.b    #%11111110,d3
  4542.         fetch_next_i
  4543.         cnop    0,128
  4544.  
  4545. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4546. ;        88 - ADC B - [n = 0, h = x, c = x, z = x]
  4547. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4548.  
  4549. z80_optcode_88:    btst    #0,d4                    ;carry?
  4550.         beq.w    z80_optcode_80                ;normal add.
  4551.  
  4552.         move.b    d3,h_other_I
  4553.         ror.w    #8,d1                    ;b down.
  4554.         subq.l    #1,a5                    ;less cycles.
  4555.         move.b    d1,h_other_II
  4556.  
  4557.         move.w    #%10000,CCR                ;x = 1!
  4558.         addx.b    d1,d3                    ;a = a + b + c.
  4559.         move.w    CCR,d4                    ;status updated.
  4560.  
  4561.         rol.w    #8,d1                    ;b back to up.
  4562.         move.w    #$0102,h_with_carry            ;yes carry! h = x!
  4563.         and.w    #$ff,d3                    ;n = 0!
  4564.  
  4565.         fetch_next_i
  4566.         cnop    0,128
  4567.  
  4568. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4569. ;        CB88 - RES 1, B
  4570. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4571.  
  4572. z80_optc_CB88:    subq.l    #2,a5                    ;less cycles.
  4573.         and.w    #%1111110111111111,d1
  4574.         fetch_next_i
  4575.         cnop    0,128
  4576.  
  4577. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4578. ;        89 - ADC C - [n = 0, h = x, c = x, z = x]
  4579. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4580.  
  4581. z80_optcode_89:    btst    #0,d4                    ;carry?
  4582.         beq.w    z80_optcode_81                ;normal add.
  4583.  
  4584.         move.b    d3,h_other_I
  4585.         subq.l    #1,a5                    ;less cycles.
  4586.         move.b    d1,h_other_II
  4587.  
  4588.         move.w    #%10000,CCR                ;x = 1!
  4589.         addx.b    d1,d3                    ;a = a + c + c.
  4590.         move.w    CCR,d4                    ;status updated.
  4591.  
  4592.         move.w    #$0102,h_with_carry            ;yes carry! h = x!
  4593.         and.w    #$ff,d3                    ;n = 0!
  4594.  
  4595.         fetch_next_i
  4596.         cnop    0,128
  4597.  
  4598. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4599. ;        CB89 - RES 1, C
  4600. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4601.  
  4602. z80_optc_CB89:    subq.l    #2,a5                    ;less cycles.
  4603.         and.b    #%11111101,d1
  4604.         fetch_next_i
  4605.         cnop    0,128
  4606.  
  4607. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4608. ;        8A - ADC D - [n = 0, h = x, c = x, z = x]
  4609. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4610.  
  4611. z80_optcode_8A:    btst    #0,d4                    ;carry?
  4612.         beq.w    z80_optcode_82                ;normal add.
  4613.  
  4614.         move.b    d3,h_other_I
  4615.         ror.w    #8,d0                    ;d down.
  4616.         subq.l    #1,a5                    ;less cycles.
  4617.         move.b    d0,h_other_II
  4618.  
  4619.         move.w    #%10000,CCR                ;x = 1!
  4620.         addx.b    d0,d3                    ;a = a + d + c.
  4621.         move.w    CCR,d4                    ;status updated.
  4622.  
  4623.         rol.w    #8,d0                    ;d back to up.
  4624.         move.w    #$0102,h_with_carry            ;yes carry! h = x!
  4625.         and.w    #$ff,d3                    ;n = 0!
  4626.  
  4627.         fetch_next_i
  4628.         cnop    0,128
  4629.  
  4630. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4631. ;        CB8A - RES 1, D
  4632. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4633.  
  4634. z80_optc_CB8A:    subq.l    #2,a5                    ;less cycles.
  4635.         and.w    #%1111110111111111,d0
  4636.         fetch_next_i
  4637.         cnop    0,128
  4638.  
  4639. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4640. ;        8B - ADC E - [n = 0, h = x, c = x, z = x]
  4641. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4642.  
  4643. z80_optcode_8B:    btst    #0,d4                    ;carry?
  4644.         beq.w    z80_optcode_83                ;normal add.
  4645.  
  4646.         move.b    d3,h_other_I
  4647.         subq.l    #1,a5                    ;less cycles.
  4648.         move.b    d0,h_other_II
  4649.  
  4650.         move.w    #%10000,CCR                ;x = 1!
  4651.         addx.b    d0,d3                    ;a = a + e + c.
  4652.         move.w    CCR,d4                    ;status updated.
  4653.  
  4654.         move.w    #$0102,h_with_carry            ;yes carry! h = x!
  4655.         and.w    #$ff,d3                    ;n = 0!
  4656.  
  4657.         fetch_next_i
  4658.         cnop    0,128
  4659.  
  4660. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4661. ;        CB8B - RES 1, E
  4662. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4663.  
  4664. z80_optc_CB8B:    subq.l    #2,a5                    ;less cycles.
  4665.         and.b    #%11111101,d0
  4666.         fetch_next_i
  4667.         cnop    0,128
  4668.  
  4669. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4670. ;        8C - ADC H - [n = 0, h = x, c = x, z = x]
  4671. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4672.  
  4673. z80_optcode_8C:    btst    #0,d4                    ;carry?
  4674.         beq.w    z80_optcode_84                ;normal add.
  4675.  
  4676.         move.b    d3,h_other_I
  4677.         ror.w    #8,d2                    ;h down.
  4678.         subq.l    #1,a5                    ;less cycles.
  4679.         move.b    d2,h_other_II
  4680.  
  4681.         move.w    #%10000,CCR                ;x = 1!
  4682.         addx.b    d2,d3                    ;a = a + h + c.
  4683.         move.w    CCR,d4                    ;status updated.
  4684.  
  4685.         rol.w    #8,d2                    ;h back to up.
  4686.         move.w    #$0102,h_with_carry            ;yes carry! h = x!
  4687.         and.w    #$ff,d3                    ;n = 0!
  4688.  
  4689.         fetch_next_i
  4690.         cnop    0,128
  4691.  
  4692. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4693. ;        CB8C - RES 1, H
  4694. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4695.  
  4696. z80_optc_CB8C:    subq.l    #2,a5                    ;less cycles.
  4697.         and.w    #%1111110111111111,d2
  4698.         fetch_next_i
  4699.         cnop    0,128
  4700.  
  4701. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4702. ;        8D - ADC L - [n = 0, h = x, c = x, z = x]
  4703. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4704.  
  4705. z80_optcode_8D:    btst    #0,d4                    ;carry?
  4706.         beq.w    z80_optcode_85                ;normal add.
  4707.  
  4708.         move.b    d3,h_other_I
  4709.         subq.l    #1,a5                    ;less cycles.
  4710.         move.b    d2,h_other_II
  4711.  
  4712.         move.w    #%10000,CCR                ;x = 1!
  4713.         addx.b    d2,d3                    ;a = a + l + c.
  4714.         move.w    CCR,d4                    ;status updated.
  4715.  
  4716.         move.w    #$0102,h_with_carry            ;yes carry! h = x!
  4717.         and.w    #$ff,d3                    ;n = 0!
  4718.  
  4719.         fetch_next_i
  4720.         cnop    0,128
  4721.  
  4722. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4723. ;        CB8D - RES 1, L
  4724. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4725.  
  4726. z80_optc_CB8D:    subq.l    #2,a5                    ;less cycles.
  4727.         and.b    #%11111101,d2
  4728.         fetch_next_i
  4729.         cnop    0,128
  4730.  
  4731. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4732. ;        8E - ADC (HL) - [n = 0, h = x, c = x, z = x]
  4733. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4734.  
  4735. z80_optcode_8E:    btst    #0,d4                    ;carry?
  4736.         beq.w    z80_optcode_86                ;normal add.
  4737.  
  4738.         READ_D2_TO_D6
  4739.  
  4740.         move.b    d3,h_other_I
  4741.         subq.l    #2,a5                    ;less cycles.
  4742.         move.b    d6,h_other_II
  4743.  
  4744.         move.w    #%10000,CCR                ;x = 1!
  4745.         addx.b    d6,d3                    ;a = a + d + c.
  4746.         move.w    CCR,d4                    ;status updated.
  4747.  
  4748.         move.w    #$0102,h_with_carry            ;yes carry! h = x!
  4749.         and.w    #$ff,d3                    ;n = 0!
  4750.  
  4751.         fetch_next_i
  4752.         cnop    0,128
  4753.  
  4754. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4755. ;        CB8E - RES 1, (HL)
  4756. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4757.  
  4758. z80_optc_CB8E:    subq.l    #4,a5
  4759.         READ_D2_TO_D6
  4760.         and.b    #%11111101,d6
  4761.         move.w    d2,d7                    ;d7 = a (hl) - write.
  4762.  
  4763.         move.l    gb_mem_jumps,a6
  4764.         jsr    ([a6,d2.l*4])                ;memory write.
  4765.  
  4766.         fetch_next_i
  4767.         cnop    0,128
  4768.  
  4769. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4770. ;        8F - ADC A - [n = 0, h = x, c = x, z = x]
  4771. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4772.  
  4773. z80_optcode_8F:    btst    #0,d4                    ;carry?
  4774.         beq.w    z80_optcode_87                ;normal add.
  4775.  
  4776.         move.b    d3,h_other_I
  4777.         subq.l    #1,a5                    ;less cycles.
  4778.         move.b    d3,h_other_II
  4779.  
  4780.         move.w    #%10000,CCR                ;x = 1!
  4781.         addx.b    d3,d3                    ;a = a + d + c.
  4782.         move.w    CCR,d4                    ;status updated.
  4783.  
  4784.         move.w    #$0102,h_with_carry            ;yes carry! h = x!
  4785.         and.w    #$ff,d3                    ;n = 0!
  4786.  
  4787.         fetch_next_i
  4788.         cnop    0,128
  4789.  
  4790. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4791. ;        CB8F - RES 1, A
  4792. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4793.  
  4794. z80_optc_CB8F:    subq.l    #2,a5                    ;less cycles.
  4795.         and.b    #%11111101,d3
  4796.         fetch_next_i
  4797.         cnop    0,128
  4798.  
  4799. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4800. ;        90 - SUB B - [n = 1, h = x, c = x, z = x]
  4801. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4802.  
  4803. z80_optcode_90:    move.b    d3,h_other_I
  4804.         ror.w    #8,d1                    ;b down.
  4805.         subq.l    #1,a5                    ;less cycles.
  4806.         move.b    d1,h_other_II
  4807.  
  4808.         sub.b    d1,d3                    ;a = a - b.
  4809.         move.w    CCR,d4                    ;status updated.
  4810.         rol.w    #8,d1                    ;b back to up.
  4811.  
  4812.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  4813.         or.w    #$100,d3                ;n = 1!
  4814.  
  4815.         fetch_next_i
  4816.         cnop    0,128
  4817.  
  4818. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4819. ;        CB90 - RES 2, B
  4820. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4821.  
  4822. z80_optc_CB90:    subq.l    #2,a5                    ;less cycles.
  4823.         and.w    #%1111101111111111,d1
  4824.         fetch_next_i
  4825.         cnop    0,128
  4826.  
  4827. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4828. ;        91 - SUB C - [n = 1, h = x, c = x, z = x]
  4829. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4830.  
  4831. z80_optcode_91:    move.b    d1,h_other_II
  4832.         or.w    #$100,d3                ;n = 1!
  4833.         subq.l    #1,a5                    ;less cycles.
  4834.         move.b    d3,h_other_I
  4835.  
  4836.         sub.b    d1,d3                    ;a = a - c.
  4837.         move.w    CCR,d4                    ;status updated.
  4838.  
  4839.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  4840.  
  4841.         fetch_next_i
  4842.         cnop    0,128
  4843.  
  4844. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4845. ;        CB91 - RES 2, C
  4846. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4847.  
  4848. z80_optc_CB91:    subq.l    #2,a5                    ;less cycles.
  4849.         and.b    #%11111011,d1
  4850.         fetch_next_i
  4851.         cnop    0,128
  4852.  
  4853. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4854. ;        92 - SUB D - [n = 1, h = x, c = x, z = x]
  4855. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4856.  
  4857. z80_optcode_92:    move.b    d3,h_other_I
  4858.         ror.w    #8,d0                    ;d down.
  4859.         subq.l    #1,a5                    ;less cycles.
  4860.         move.b    d0,h_other_II
  4861.  
  4862.         sub.b    d0,d3                    ;a = a - d.
  4863.         move.w    CCR,d4                    ;status updated.
  4864.  
  4865.         rol.w    #8,d0                    ;d back to up.
  4866.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  4867.         or.w    #$100,d3                ;n = 1!
  4868.  
  4869.         fetch_next_i
  4870.         cnop    0,128
  4871.  
  4872. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4873. ;        CB92 - RES 2, D
  4874. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4875.  
  4876. z80_optc_CB92:    subq.l    #2,a5                    ;less cycles.
  4877.         and.w    #%1111101111111111,d0
  4878.         fetch_next_i
  4879.         cnop    0,128
  4880.  
  4881. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4882. ;        93 - SUB E - [n = 1, h = x, c = x, z = x]
  4883. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4884.  
  4885. z80_optcode_93:    move.b    d3,h_other_I
  4886.         subq.l    #1,a5                    ;less cycles.
  4887.         or.w    #$100,d3                ;n = 1!
  4888.         move.b    d0,h_other_II
  4889.  
  4890.         sub.b    d0,d3                    ;a = a - e.
  4891.         move.w    CCR,d4                    ;status updated.
  4892.  
  4893.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  4894.  
  4895.         fetch_next_i
  4896.         cnop    0,128
  4897.  
  4898. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4899. ;        CB93 - RES 2, E
  4900. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4901.  
  4902. z80_optc_CB93:    subq.l    #2,a5                    ;less cycles.
  4903.         and.b    #%11111011,d0
  4904.         fetch_next_i
  4905.         cnop    0,128
  4906.  
  4907. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4908. ;        94 - SUB H - [n = 1, h = x, c = x, z = x]
  4909. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4910.  
  4911. z80_optcode_94:    move.b    d3,h_other_I
  4912.         ror.w    #8,d2                    ;h down.
  4913.         subq.l    #1,a5                    ;less cycles.
  4914.         move.b    d2,h_other_II
  4915.  
  4916.         sub.b    d2,d3                    ;a = a - h.
  4917.         move.w    CCR,d4                    ;status updated.
  4918.  
  4919.         rol.w    #8,d2                    ;h back to up.
  4920.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  4921.         or.w    #$100,d3                ;n = 1!
  4922.  
  4923.         fetch_next_i
  4924.         cnop    0,128
  4925.  
  4926. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4927. ;        CB94 - RES 2, H
  4928. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4929.  
  4930. z80_optc_CB94:    subq.l    #2,a5                    ;less cycles.
  4931.         and.w    #%1111101111111111,d2
  4932.         fetch_next_i
  4933.         cnop    0,128
  4934.  
  4935. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4936. ;        95 - SUB L - [n = 1, h = x, c = x, z = x]
  4937. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4938.  
  4939. z80_optcode_95:    move.b    d3,h_other_I
  4940.         subq.l    #1,a5                    ;less cycles.
  4941.         or.w    #$100,d3                ;n = 1!
  4942.         move.b    d2,h_other_II
  4943.  
  4944.         sub.b    d2,d3                    ;a = a - l.
  4945.         move.w    CCR,d4                    ;status updated.
  4946.  
  4947.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  4948.  
  4949.         fetch_next_i
  4950.         cnop    0,128
  4951.  
  4952. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4953. ;        CB95 - RES 2, L
  4954. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4955.  
  4956. z80_optc_CB95:    subq.l    #2,a5                    ;less cycles.
  4957.         and.b    #%11111011,d2
  4958.         fetch_next_i
  4959.         cnop    0,128
  4960.  
  4961. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4962. ;        96 - SUB (HL) - [n = 1, h = x, c = x, z = x]
  4963. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4964.  
  4965. z80_optcode_96:
  4966.         READ_D2_TO_D6
  4967.  
  4968.         move.b    d3,h_other_I
  4969.         subq.l    #2,a5
  4970.         or.w    #$100,d3                ;n = 1!
  4971.         move.b    d6,h_other_II
  4972.  
  4973.         sub.b    d6,d3                    ;a = a - (hl).
  4974.         move.w    CCR,d4                    ;status updated.
  4975.  
  4976.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  4977.  
  4978.         fetch_next_i
  4979.         cnop    0,128
  4980.  
  4981. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4982. ;        CB96 - RES 2, (HL)
  4983. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4984.  
  4985. z80_optc_CB96:    subq.l    #4,a5
  4986.         READ_D2_TO_D6
  4987.         and.b    #%11111011,d6
  4988.         move.w    d2,d7                    ;d7 = a (hl) - write.
  4989.  
  4990.         move.l    gb_mem_jumps,a6
  4991.         jsr    ([a6,d2.l*4])                ;memory write.
  4992.  
  4993.         fetch_next_i
  4994.         cnop    0,128
  4995.  
  4996. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4997. ;        97 - SUB A - [n = 1, h = x, c = x, z = x]
  4998. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  4999.  
  5000. z80_optcode_97:    move.b    d3,h_other_I
  5001.         subq.l    #1,a5                    ;less cycles.
  5002.         move.b    d3,h_other_II
  5003.  
  5004.         sub.b    d3,d3                    ;a = a - a (=0).
  5005.         move.w    CCR,d4                    ;status updated.
  5006.  
  5007.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  5008.         or.w    #$100,d3                ;n = 1!
  5009.  
  5010.         fetch_next_i
  5011.         cnop    0,128
  5012.  
  5013. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5014. ;        CB97 - RES 2, A
  5015. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5016.  
  5017. z80_optc_CB97:    subq.l    #2,a5                    ;less cycles.
  5018.         and.b    #%11111011,d3
  5019.         fetch_next_i
  5020.         cnop    0,128
  5021.  
  5022. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5023. ;        98 - SBC B - [n = 1, h = x, c = x, z = x]
  5024. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5025.  
  5026. z80_optcode_98:    btst    #0,d4                    ;c = 0?
  5027.         beq.w    z80_optcode_90                ;yes. normal sub.
  5028.  
  5029.         move.b    d3,h_other_I
  5030.         ror.w    #8,d1                    ;b down.
  5031.         subq.l    #1,a5                    ;less cycles.
  5032.         move.b    d1,h_other_II
  5033.  
  5034.         move.w    #%10000,CCR                ;x = 1!
  5035.         subx.b    d1,d3                    ;a = a - b - c.
  5036.         move.w    CCR,d4                    ;status updated.
  5037.  
  5038.         rol.w    #8,d1                    ;b back to up.
  5039.         move.w    #$0102,h_with_carry            ;yes carry! h = x!
  5040.         or.w    #$100,d3                ;n = 1!
  5041.  
  5042.         fetch_next_i
  5043.         cnop    0,128
  5044.  
  5045. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5046. ;        CB98 - RES 3, B
  5047. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5048.  
  5049. z80_optc_CB98:    subq.l    #2,a5                    ;less cycles.
  5050.         and.w    #%1111011111111111,d1
  5051.         fetch_next_i
  5052.         cnop    0,128
  5053.  
  5054. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5055. ;        99 - SBC C - [n = 1, h = x, c = x, z = x]
  5056. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5057.  
  5058. z80_optcode_99:    btst    #0,d4                    ;c = 0?
  5059.         beq.w    z80_optcode_91                ;yes. normal sub.
  5060.  
  5061.         move.b    d3,h_other_I
  5062.         subq.l    #1,a5                    ;less cycles.
  5063.         move.b    d1,h_other_II
  5064.  
  5065.         move.w    #%10000,CCR                ;x = 1!
  5066.         subx.b    d1,d3                    ;a = a - c - c.
  5067.         move.w    CCR,d4                    ;status updated.
  5068.  
  5069.         move.w    #$0102,h_with_carry            ;yes carry! h = x!
  5070.         or.w    #$100,d3                ;n = 1!
  5071.  
  5072.         fetch_next_i
  5073.         cnop    0,128
  5074.  
  5075. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5076. ;        CB99 - RES 3, C
  5077. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5078.  
  5079. z80_optc_CB99:    subq.l    #2,a5                    ;less cycles.
  5080.         and.b    #%11110111,d1
  5081.         fetch_next_i
  5082.         cnop    0,128
  5083.  
  5084. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5085. ;        9A - SBC D - [n = 1, h = x, c = x, z = x]
  5086. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5087.  
  5088. z80_optcode_9A:    btst    #0,d4                    ;c = 0?
  5089.         beq.w    z80_optcode_92                ;yes. normal sub.
  5090.  
  5091.         move.b    d3,h_other_I
  5092.         ror.w    #8,d0                    ;d down.
  5093.         subq.l    #1,a5                    ;less cycles.
  5094.         move.b    d0,h_other_II
  5095.  
  5096.         move.w    #%10000,CCR                ;x = 1!
  5097.         subx.b    d0,d3                    ;a = a - d - c.
  5098.         move.w    CCR,d4                    ;status updated.
  5099.  
  5100.         rol.w    #8,d0                    ;d back to up.
  5101.         move.w    #$0102,h_with_carry            ;yes carry! h = x!
  5102.         or.w    #$100,d3                ;n = 1!
  5103.  
  5104.         fetch_next_i
  5105.         cnop    0,128
  5106.  
  5107. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5108. ;        CB9A - RES 3, D
  5109. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5110.  
  5111. z80_optc_CB9A:    subq.l    #2,a5                    ;less cycles.
  5112.         and.w    #%1111011111111111,d0
  5113.         fetch_next_i
  5114.         cnop    0,128
  5115.  
  5116. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5117. ;        9B - SBC E - [n = 1, h = x, c = x, z = x]
  5118. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5119.  
  5120. z80_optcode_9B:    btst    #0,d4                    ;c = 0?
  5121.         beq.w    z80_optcode_93                ;yes. normal sub.
  5122.  
  5123.         move.b    d3,h_other_I
  5124.         subq.l    #1,a5                    ;less cycles.
  5125.         move.b    d0,h_other_II
  5126.  
  5127.         move.w    #%10000,CCR                ;x = 1!
  5128.         subx.b    d0,d3                    ;a = a - e - c.
  5129.         move.w    CCR,d4                    ;status updated.
  5130.  
  5131.         move.w    #$0102,h_with_carry            ;yes carry! h = x!
  5132.         or.w    #$100,d3                ;n = 1!
  5133.  
  5134.         fetch_next_i
  5135.         cnop    0,128
  5136.  
  5137. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5138. ;        CB9B - RES 3, E
  5139. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5140.  
  5141. z80_optc_CB9B:    subq.l    #2,a5                    ;less cycles.
  5142.         and.b    #%11110111,d0
  5143.         fetch_next_i
  5144.         cnop    0,128
  5145.  
  5146. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5147. ;        9C - SBC H - [n = 1, h = x, c = x, z = x]
  5148. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5149.  
  5150. z80_optcode_9C:    btst    #0,d4                    ;c = 0?
  5151.         beq.w    z80_optcode_94                ;yes. normal sub.
  5152.  
  5153.         move.b    d3,h_other_I
  5154.         ror.w    #8,d2                    ;h down.
  5155.         subq.l    #1,a5                    ;less cycles.
  5156.         move.b    d2,h_other_II
  5157.  
  5158.         move.w    #%10000,CCR                ;x = 1!
  5159.         subx.b    d2,d3                    ;a = a - h - c.
  5160.         move.w    CCR,d4                    ;status updated.
  5161.  
  5162.         rol.w    #8,d2                    ;h back to up.
  5163.         move.w    #$0102,h_with_carry            ;yes carry! h = x!
  5164.         or.w    #$100,d3                ;n = 1!
  5165.  
  5166.         fetch_next_i
  5167.         cnop    0,128
  5168.  
  5169. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5170. ;        CB9C - RES 3, H
  5171. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5172.  
  5173. z80_optc_CB9C:    subq.l    #2,a5                    ;less cycles.
  5174.         and.w    #%1111011111111111,d2
  5175.         fetch_next_i
  5176.         cnop    0,128
  5177.  
  5178. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5179. ;        9D - SBC L - [n = 1, h = x, c = x, z = x]
  5180. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5181.  
  5182. z80_optcode_9D:    btst    #0,d4                    ;c = 0?
  5183.         beq.w    z80_optcode_95                ;yes. normal sub.
  5184.  
  5185.         move.b    d3,h_other_I
  5186.         subq.l    #1,a5                    ;less cycles.
  5187.         move.b    d2,h_other_II
  5188.  
  5189.         move.w    #%10000,CCR                ;x = 1!
  5190.         subx.b    d2,d3                    ;a = a - l - c.
  5191.         move.w    CCR,d4                    ;status updated.
  5192.  
  5193.         move.w    #$0102,h_with_carry            ;yes carry! h = x!
  5194.         or.w    #$100,d3                ;n = 1!
  5195.  
  5196.         fetch_next_i
  5197.         cnop    0,128
  5198.  
  5199. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5200. ;        CB9D - RES 3, L
  5201. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5202.  
  5203. z80_optc_CB9D:    subq.l    #2,a5                    ;less cycles.
  5204.         and.b    #%11110111,d2
  5205.         fetch_next_i
  5206.         cnop    0,128
  5207.  
  5208. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5209. ;        9E - SBC (HL) - [n = 1, h = x, c = x, z = x]
  5210. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5211.  
  5212. z80_optcode_9E:    btst    #0,d4                    ;c = 0?
  5213.         beq.w    z80_optcode_96                ;yes. normal sub.
  5214.  
  5215.         READ_D2_TO_D6
  5216.  
  5217.         move.b    d3,h_other_I
  5218.         subq.l    #2,a5                    ;less cycles.
  5219.         move.b    d6,h_other_II
  5220.  
  5221.         move.w    #%10000,CCR                ;x = 1!
  5222.         subx.b    d6,d3                    ;a = a - (hl) - c.
  5223.         move.w    CCR,d4                    ;status updated.
  5224.  
  5225.         move.w    #$0102,h_with_carry            ;yes carry! h = x!
  5226.         or.w    #$100,d3                ;n = 1!
  5227.  
  5228.         fetch_next_i
  5229.         cnop    0,128
  5230.  
  5231. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5232. ;        CB9E - RES 3, (HL)
  5233. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5234.  
  5235. z80_optc_CB9E:    subq.l    #4,a5
  5236.         READ_D2_TO_D6
  5237.         and.b    #%11110111,d6
  5238.         move.w    d2,d7                    ;d7 = a (hl) - write.
  5239.  
  5240.         move.l    gb_mem_jumps,a6
  5241.         jsr    ([a6,d2.l*4])                ;memory write.
  5242.  
  5243.         fetch_next_i
  5244.         cnop    0,128
  5245.  
  5246. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5247. ;        9F - SBC A - [n = 1, h = x, c = x, z = x]
  5248. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5249.  
  5250. z80_optcode_9F:    btst    #0,d4                    ;c = 0?
  5251.         beq.w    z80_optcode_97                ;yes. normal sub.
  5252.  
  5253.         move.b    d3,h_other_I
  5254.         subq.l    #1,a5                    ;less cycles.
  5255.         move.b    d3,h_other_II
  5256.  
  5257.         move.w    #%10000,CCR                ;x = 1!
  5258.         subx.b    d3,d3                    ;a = a - a - c.
  5259.         move.w    CCR,d4                    ;status updated.
  5260.  
  5261.         move.w    #$0102,h_with_carry            ;yes carry! h = x!
  5262.         or.w    #$100,d3                ;n = 1!
  5263.  
  5264.         fetch_next_i
  5265.         cnop    0,128
  5266.  
  5267. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5268. ;        CB9F - RES 3, A
  5269. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5270.  
  5271. z80_optc_CB9F:    subq.l    #2,a5                    ;less cycles.
  5272.         and.b    #%11110111,d3
  5273.         fetch_next_i
  5274.         cnop    0,128
  5275.  
  5276. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5277. ;        A0 - AND B - [n = 0, h = 1, c = 0, z = x]
  5278. ;        MC680x0 CLEARS THE CARRY FLAG ITSELF!
  5279. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5280.  
  5281. z80_optcode_A0:    ror.w    #8,d1                    ;b down.
  5282.         subq.l    #1,a5                    ;less cycles.
  5283.         and.b    d1,d3
  5284.         move.w    CCR,d4                    ;status updated.
  5285.         rol.w    #8,d1                    ;b back to up.
  5286.  
  5287.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  5288.         and.w    #$ff,d3                    ;n = 0!
  5289.  
  5290.         fetch_next_i
  5291.         cnop    0,128
  5292.  
  5293. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5294. ;        CBA0 - RES 4, B
  5295. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5296.  
  5297. z80_optc_CBA0:    subq.l    #2,a5                    ;less cycles.
  5298.         and.w    #%1110111111111111,d1
  5299.         fetch_next_i
  5300.         cnop    0,128
  5301.  
  5302. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5303. ;        A1 - AND C - [n = 0, h = 1, c = 0, z = x]
  5304. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5305.  
  5306. z80_optcode_A1:    subq.l    #1,a5                    ;less cycles.
  5307.         and.b    d1,d3
  5308.         move.w    CCR,d4                    ;status updated.
  5309.  
  5310.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  5311.         and.w    #$ff,d3                    ;n = 0!
  5312.  
  5313.         fetch_next_i
  5314.         cnop    0,128
  5315.  
  5316. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5317. ;        CBA1 - RES 4, C
  5318. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5319.  
  5320. z80_optc_CBA1:    subq.l    #2,a5                    ;less cycles.
  5321.         and.b    #%11101111,d1
  5322.         fetch_next_i
  5323.         cnop    0,128
  5324.  
  5325. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5326. ;        A2 - AND D - [n = 0, h = 1, c = 0, z = x]
  5327. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5328.  
  5329. z80_optcode_A2:    ror.w    #8,d0                    ;d down.
  5330.         subq.l    #1,a5                    ;less cycles.
  5331.         and.b    d0,d3
  5332.         move.w    CCR,d4                    ;status updated.
  5333.         rol.w    #8,d0                    ;d back to up.
  5334.  
  5335.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  5336.         and.w    #$ff,d3                    ;n = 0!
  5337.  
  5338.         fetch_next_i
  5339.         cnop    0,128
  5340.  
  5341. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5342. ;        CBA2 - RES 4, D
  5343. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5344.  
  5345. z80_optc_CBA2:    subq.l    #2,a5                    ;less cycles.
  5346.         and.w    #%1110111111111111,d0
  5347.         fetch_next_i
  5348.         cnop    0,128
  5349.  
  5350. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5351. ;        A3 - AND E - [n = 0, h = 1, c = 0, z = x]
  5352. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5353.  
  5354. z80_optcode_A3:    subq.l    #1,a5                    ;less cycles.
  5355.         and.b    d0,d3
  5356.         move.w    CCR,d4                    ;status updated.
  5357.  
  5358.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  5359.         and.w    #$ff,d3                    ;n = 0!
  5360.  
  5361.         fetch_next_i
  5362.         cnop    0,128
  5363.  
  5364. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5365. ;        CBA3 - RES 4, E
  5366. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5367.  
  5368. z80_optc_CBA3:    subq.l    #2,a5                    ;less cycles.
  5369.         and.b    #%11101111,d0
  5370.         fetch_next_i
  5371.         cnop    0,128
  5372.  
  5373. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5374. ;        A4 - AND H - [n = 0, h = 1, c = 0, z = x]
  5375. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5376.  
  5377. z80_optcode_A4:    ror.w    #8,d2                    ;h down.
  5378.         subq.l    #1,a5                    ;less cycles.
  5379.         and.b    d2,d3
  5380.         move.w    CCR,d4                    ;status updated.
  5381.         rol.w    #8,d2                    ;h back to up.
  5382.  
  5383.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  5384.         and.w    #$ff,d3                    ;n = 0!
  5385.  
  5386.         fetch_next_i
  5387.         cnop    0,128
  5388.  
  5389. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5390. ;        CBA4 - RES 4, H
  5391. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5392.  
  5393. z80_optc_CBA4:    subq.l    #2,a5                    ;less cycles.
  5394.         and.w    #%1110111111111111,d2
  5395.         fetch_next_i
  5396.         cnop    0,128
  5397.  
  5398. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5399. ;        A5 - AND L - [n = 0, h = 1, c = 0, z = x]
  5400. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5401.  
  5402. z80_optcode_A5:    subq.l    #1,a5                    ;less cycles.
  5403.         and.b    d2,d3
  5404.         move.w    CCR,d4                    ;status updated.
  5405.  
  5406.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  5407.         and.w    #$ff,d3                    ;n = 0!
  5408.  
  5409.         fetch_next_i
  5410.         cnop    0,128
  5411.  
  5412. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5413. ;        CBA5 - RES 4, L
  5414. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5415.  
  5416. z80_optc_CBA5:    subq.l    #2,a5                    ;less cycles.
  5417.         and.b    #%11101111,d2
  5418.         fetch_next_i
  5419.         cnop    0,128
  5420.  
  5421. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5422. ;        A6 - AND (HL) - [n = 0, h = 1, c = 0, z = x]
  5423. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5424.  
  5425. z80_optcode_A6:
  5426.         READ_D2_TO_D6
  5427.         subq.l    #2,a5                    ;less cycles.
  5428.         and.b    d6,d3
  5429.         move.w    CCR,d4                    ;status updated.
  5430.  
  5431.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  5432.         and.w    #$ff,d3                    ;n = 0!
  5433.  
  5434.         fetch_next_i
  5435.         cnop    0,128
  5436.  
  5437. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5438. ;        CBA6 - RES 4, (HL)
  5439. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5440.  
  5441. z80_optc_CBA6:    subq.l    #4,a5
  5442.         READ_D2_TO_D6
  5443.         and.b    #%11101111,d6
  5444.         move.w    d2,d7                    ;d7 = a (hl) - write.
  5445.  
  5446.         move.l    gb_mem_jumps,a6
  5447.         jsr    ([a6,d2.l*4])                ;memory write.
  5448.  
  5449.         fetch_next_i
  5450.         cnop    0,128
  5451.  
  5452. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5453. ;        A7 - AND A - [n = 0, h = 1, c = 0, z = x]
  5454. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5455.  
  5456. z80_optcode_A7:    subq.l    #1,a5                    ;less cycles.
  5457.         and.b    d3,d3
  5458.         move.w    CCR,d4                    ;status updated.
  5459.  
  5460.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  5461.         and.w    #$ff,d3                    ;n = 0!
  5462.  
  5463.         fetch_next_i
  5464.         cnop    0,128
  5465.  
  5466. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5467. ;        CBA7 - RES 4, A
  5468. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5469.  
  5470. z80_optc_CBA7:    subq.l    #2,a5                    ;less cycles.
  5471.         and.b    #%11101111,d3
  5472.         fetch_next_i
  5473.         cnop    0,128
  5474.  
  5475. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5476. ;        A8 - XOR B - [n = 0, h = 0, c = 0, z = x]
  5477. ;        MC680x0 CLEARS THE CARRY FLAG ITSELF!
  5478. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5479.  
  5480. z80_optcode_A8:    ror.w    #8,d1                    ;b down.
  5481.         subq.l    #1,a5                    ;less cycles.
  5482.         eor.b    d1,d3
  5483.         move.w    CCR,d4                    ;status updated.
  5484.         rol.w    #8,d1                    ;b back to up.
  5485.  
  5486.         clr.l    h_other_I                ;h = 0! no carry!
  5487.         and.w    #$ff,d3                    ;n = 0!
  5488.  
  5489.         fetch_next_i
  5490.         cnop    0,128
  5491.  
  5492. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5493. ;        CBA8 - RES 5, B
  5494. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5495.  
  5496. z80_optc_CBA8:    subq.l    #2,a5                    ;less cycles.
  5497.         and.w    #%1101111111111111,d1
  5498.         fetch_next_i
  5499.         cnop    0,128
  5500.  
  5501. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5502. ;        A9 - XOR C - [n = 0, h = 0, c = 0, z = x]
  5503. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5504.  
  5505. z80_optcode_A9:    subq.l    #1,a5                    ;less cycles.
  5506.         eor.b    d1,d3
  5507.         move.w    CCR,d4                    ;status updated.
  5508.  
  5509.         clr.l    h_other_I                ;h = 0! no carry!
  5510.         and.w    #$ff,d3                    ;n = 0!
  5511.  
  5512.         fetch_next_i
  5513.         cnop    0,128
  5514.  
  5515. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5516. ;        CBA9 - RES 5, C
  5517. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5518.  
  5519. z80_optc_CBA9:    subq.l    #2,a5                    ;less cycles.
  5520.         and.b    #%11011111,d1
  5521.         fetch_next_i
  5522.         cnop    0,128
  5523.  
  5524. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5525. ;        AA - XOR D - [n = 0, h = 0, c = 0, z = x]
  5526. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5527.  
  5528. z80_optcode_AA:    ror.w    #8,d0                    ;d down.
  5529.         subq.l    #1,a5                    ;less cycles.
  5530.         eor.b    d0,d3
  5531.         move.w    CCR,d4                    ;status updated.
  5532.         rol.w    #8,d0                    ;d back to up.
  5533.  
  5534.         clr.l    h_other_I                ;h = 0! no carry!
  5535.         and.w    #$ff,d3                    ;n = 0!
  5536.  
  5537.         fetch_next_i
  5538.         cnop    0,128
  5539.  
  5540. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5541. ;        CBAA - RES 5, D
  5542. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5543.  
  5544. z80_optc_CBAA:    subq.l    #2,a5                    ;less cycles.
  5545.         and.w    #%1101111111111111,d0
  5546.         fetch_next_i
  5547.         cnop    0,128
  5548.  
  5549. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5550. ;        AB - XOR E - [n = 0, h = 0, c = 0, z = x]
  5551. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5552.  
  5553. z80_optcode_AB:    subq.l    #1,a5                    ;less cycles.
  5554.         eor.b    d0,d3
  5555.         move.w    CCR,d4                    ;status updated.
  5556.  
  5557.         clr.l    h_other_I                ;h = 0! no carry!
  5558.         and.w    #$ff,d3                    ;n = 0!
  5559.  
  5560.         fetch_next_i
  5561.         cnop    0,128
  5562.  
  5563. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5564. ;        CBAB - RES 5, E
  5565. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5566.  
  5567. z80_optc_CBAB:    subq.l    #2,a5                    ;less cycles.
  5568.         and.b    #%11011111,d0
  5569.         fetch_next_i
  5570.         cnop    0,128
  5571.  
  5572. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5573. ;        AC - XOR H - [n = 0, h = 0, c = 0, z = x]
  5574. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5575.  
  5576. z80_optcode_AC:    ror.w    #8,d2                    ;h down.
  5577.         subq.l    #1,a5                    ;less cycles.
  5578.         eor.b    d2,d3
  5579.         move.w    CCR,d4                    ;status updated.
  5580.         rol.w    #8,d2                    ;h back to up.
  5581.  
  5582.         clr.l    h_other_I                ;h = 0! no carry!
  5583.         and.w    #$ff,d3                    ;n = 0!
  5584.  
  5585.         fetch_next_i
  5586.         cnop    0,128
  5587.  
  5588. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5589. ;        CBAC - RES 5, H
  5590. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5591.  
  5592. z80_optc_CBAC:    subq.l    #2,a5                    ;less cycles.
  5593.         and.w    #%1101111111111111,d2
  5594.         fetch_next_i
  5595.         cnop    0,128
  5596.  
  5597. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5598. ;        AD - XOR L - [n = 0, h = 0, c = 0, z = x]
  5599. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5600.  
  5601. z80_optcode_AD:    subq.l    #1,a5                    ;less cycles.
  5602.         eor.b    d2,d3
  5603.         move.w    CCR,d4                    ;status updated.
  5604.  
  5605.         clr.l    h_other_I                ;h = 0! no carry!
  5606.         and.w    #$ff,d3                    ;n = 0!
  5607.  
  5608.         fetch_next_i
  5609.         cnop    0,128
  5610.  
  5611. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5612. ;        CBAD - RES 5, L
  5613. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5614.  
  5615. z80_optc_CBAD:    subq.l    #2,a5                    ;less cycles.
  5616.         and.b    #%11011111,d2
  5617.         fetch_next_i
  5618.         cnop    0,128
  5619.  
  5620. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5621. ;        AE - XOR (HL) - [n = 0, h = 0, c = 0, z = x]
  5622. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5623.  
  5624. z80_optcode_AE:
  5625.         READ_D2_TO_D6
  5626.         subq.l    #2,a5                    ;less cycles.
  5627.         eor.b    d6,d3
  5628.         move.w    CCR,d4                    ;status updated.
  5629.  
  5630.         clr.l    h_other_I                ;h = 0! no carry!
  5631.         and.w    #$ff,d3                    ;n = 0!
  5632.  
  5633.         fetch_next_i
  5634.         cnop    0,128
  5635.  
  5636. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5637. ;        CBAE - RES 5, (HL)
  5638. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5639.  
  5640. z80_optc_CBAE:    subq.l    #4,a5
  5641.         READ_D2_TO_D6
  5642.         and.b    #%11011111,d6
  5643.         move.w    d2,d7                    ;d7 = a (hl) - write.
  5644.  
  5645.         move.l    gb_mem_jumps,a6
  5646.         jsr    ([a6,d2.l*4])                ;memory write.
  5647.  
  5648.         fetch_next_i
  5649.         cnop    0,128
  5650.  
  5651. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5652. ;        AF - XOR A - [n = 0, h = 0, c = 0, z = x]
  5653. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5654.  
  5655. z80_optcode_AF:    subq.l    #1,a5                    ;less cycles.
  5656.         eor.b    d3,d3
  5657.         move.w    CCR,d4                    ;status updated.
  5658.  
  5659.         clr.l    h_other_I                ;h = 0! no carry!
  5660.         and.w    #$ff,d3                    ;n = 0!
  5661.  
  5662.         fetch_next_i
  5663.         cnop    0,128
  5664.  
  5665. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5666. ;        CBAF - RES 5, A
  5667. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5668.  
  5669. z80_optc_CBAF:    subq.l    #2,a5                    ;less cycles.
  5670.         and.b    #%11011111,d3
  5671.         fetch_next_i
  5672.         cnop    0,128
  5673.  
  5674. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5675. ;        B0 - OR B - [n = 0, h = 0, c = 0, z = x]
  5676. ;        MC680x0 CLEARS THE CARRY FLAG ITSELF!
  5677. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5678.  
  5679. z80_optcode_B0:    ror.w    #8,d1                    ;b down.
  5680.         subq.l    #1,a5                    ;less cycles.
  5681.         or.b    d1,d3
  5682.         move.w    CCR,d4                    ;status updated.
  5683.         rol.w    #8,d1                    ;b back to up.
  5684.  
  5685.         clr.l    h_other_I                ;h = 0! no carry!
  5686.         and.w    #$ff,d3                    ;n = 0!
  5687.  
  5688.         fetch_next_i
  5689.         cnop    0,128
  5690.  
  5691. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5692. ;        CBB0 - RES 6, B
  5693. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5694.  
  5695. z80_optc_CBB0:    subq.l    #2,a5                    ;less cycles.
  5696.         and.w    #%1011111111111111,d1
  5697.         fetch_next_i
  5698.         cnop    0,128
  5699.  
  5700. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5701. ;        B1 - OR C - [n = 0, h = 0, c = 0, z = x]
  5702. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5703.  
  5704. z80_optcode_B1:    subq.l    #1,a5                    ;less cycles.
  5705.         or.b    d1,d3
  5706.         move.w    CCR,d4                    ;status updated.
  5707.  
  5708.         clr.l    h_other_I                ;h = 0! no carry!
  5709.         and.w    #$ff,d3                    ;n = 0!
  5710.  
  5711.         fetch_next_i
  5712.         cnop    0,128
  5713.  
  5714. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5715. ;        CBB1 - RES 6, C
  5716. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5717.  
  5718. z80_optc_CBB1:    subq.l    #2,a5                    ;less cycles.
  5719.         and.b    #%10111111,d1
  5720.         fetch_next_i
  5721.         cnop    0,128
  5722.  
  5723. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5724. ;        B2 - OR D - [n = 0, h = 0, c = 0, z = x]
  5725. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5726.  
  5727. z80_optcode_B2:    ror.w    #8,d0                    ;d down.
  5728.         subq.l    #1,a5                    ;less cycles.
  5729.         or.b    d0,d3
  5730.         move.w    CCR,d4                    ;status updated.
  5731.         rol.w    #8,d0                    ;d back to up.
  5732.  
  5733.         clr.l    h_other_I                ;h = 0! no carry!
  5734.         and.w    #$ff,d3                    ;n = 0!
  5735.  
  5736.         fetch_next_i
  5737.         cnop    0,128
  5738.  
  5739. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5740. ;        CBB2 - RES 6, D
  5741. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5742.  
  5743. z80_optc_CBB2:    subq.l    #2,a5                    ;less cycles.
  5744.         and.w    #%1011111111111111,d0
  5745.         fetch_next_i
  5746.         cnop    0,128
  5747.  
  5748. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5749. ;        B3 - OR E - [n = 0, h = 0, c = 0, z = x]
  5750. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5751.  
  5752. z80_optcode_B3:    subq.l    #1,a5                    ;less cycles.
  5753.         or.b    d0,d3
  5754.         move.w    CCR,d4                    ;status updated.
  5755.  
  5756.         clr.l    h_other_I                ;h = 0! no carry!
  5757.         and.w    #$ff,d3                    ;n = 0!
  5758.  
  5759.         fetch_next_i
  5760.         cnop    0,128
  5761.  
  5762. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5763. ;        CBB3 - RES 6, E
  5764. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5765.  
  5766. z80_optc_CBB3:    subq.l    #2,a5                    ;less cycles.
  5767.         and.b    #%10111111,d0
  5768.         fetch_next_i
  5769.         cnop    0,128
  5770.  
  5771. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5772. ;        B4 - OR H - [n = 0, h = 0, c = 0, z = x]
  5773. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5774.  
  5775. z80_optcode_B4:    ror.w    #8,d2                    ;h down.
  5776.         subq.l    #1,a5
  5777.         or.b    d2,d3
  5778.         move.w    CCR,d4                    ;status updated.
  5779.         rol.w    #8,d2                    ;h back to up.
  5780.  
  5781.         clr.l    h_other_I                ;h = 0! no carry!
  5782.         and.w    #$ff,d3                    ;n = 0!
  5783.  
  5784.         fetch_next_i
  5785.         cnop    0,128
  5786.  
  5787. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5788. ;        CBB4 - RES 6, H
  5789. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5790.  
  5791. z80_optc_CBB4:    subq.l    #2,a5                    ;less cycles.
  5792.         and.w    #%1011111111111111,d2
  5793.         fetch_next_i
  5794.         cnop    0,128
  5795.  
  5796. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5797. ;        B5 - OR L - [n = 0, h = 0, c = 0, z = x]
  5798. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5799.  
  5800. z80_optcode_B5:    subq.l    #1,a5
  5801.         or.b    d2,d3
  5802.         move.w    CCR,d4                    ;status updated.
  5803.  
  5804.         clr.l    h_other_I                ;h = 0! no carry!
  5805.         and.w    #$ff,d3                    ;n = 0!
  5806.  
  5807.         fetch_next_i
  5808.         cnop    0,128
  5809.  
  5810. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5811. ;        CBB5 - RES 6, L
  5812. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5813.  
  5814. z80_optc_CBB5:    subq.l    #2,a5                    ;less cycles.
  5815.         and.b    #%10111111,d2
  5816.         fetch_next_i
  5817.         cnop    0,128
  5818.  
  5819. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5820. ;        B6 - OR (HL) - [n = 0, h = 0, c = 0, z = x]
  5821. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5822.  
  5823. z80_optcode_B6:
  5824.         READ_D2_TO_D6
  5825.         subq.l    #2,a5
  5826.         or.b    d6,d3
  5827.         move.w    CCR,d4                    ;status updated.
  5828.  
  5829.         clr.l    h_other_I                ;h = 0! no carry!
  5830.         and.w    #$ff,d3                    ;n = 0!
  5831.  
  5832.         fetch_next_i
  5833.         cnop    0,128
  5834.  
  5835. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5836. ;        CBB6 - RES 6, (HL)
  5837. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5838.  
  5839. z80_optc_CBB6:    subq.l    #4,a5
  5840.         READ_D2_TO_D6
  5841.         and.b    #%10111111,d6
  5842.         move.w    d2,d7                    ;d7 = a (hl) - write.
  5843.  
  5844.         move.l    gb_mem_jumps,a6
  5845.         jsr    ([a6,d2.l*4])                ;memory write.
  5846.  
  5847.         fetch_next_i
  5848.         cnop    0,128
  5849.  
  5850. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5851. ;        B7 - OR A - [n = 0, h = 0, c = 0, z = x]
  5852. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5853.  
  5854. z80_optcode_B7:    subq.l    #1,a5
  5855.         or.b    d3,d3
  5856.         move.w    CCR,d4                    ;status updated.
  5857.  
  5858.         clr.l    h_other_I                ;h = 0! no carry!
  5859.         and.w    #$ff,d3                    ;n = 0!
  5860.  
  5861.         fetch_next_i
  5862.         cnop    0,128
  5863.  
  5864. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5865. ;        CBB7 - RES 6, A
  5866. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5867.  
  5868. z80_optc_CBB7:    subq.l    #2,a5                    ;less cycles.
  5869.         and.b    #%10111111,d3
  5870.         fetch_next_i
  5871.         cnop    0,128
  5872.  
  5873. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5874. ;        B8 - CP B - [n = 1, h = x, c = x, z = x]
  5875. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5876.  
  5877. z80_optcode_B8:    move.b    d3,h_other_I
  5878.         ror.w    #8,d1                    ;b down.
  5879.         move.b    d1,h_other_II
  5880.         subq.l    #1,a5
  5881.  
  5882.         cmp.b    d1,d3
  5883.         move.w    CCR,d4                    ;status updated.
  5884.  
  5885.         rol.w    #8,d1                    ;b back to up.
  5886.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  5887.         or.w    #$100,d3                ;n = 1!
  5888.  
  5889.         fetch_next_i
  5890.         cnop    0,128
  5891.  
  5892. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5893. ;        CBB8 - RES 7, B
  5894. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5895.  
  5896. z80_optc_CBB8:    subq.l    #2,a5                    ;less cycles.
  5897.         and.w    #%0111111111111111,d1
  5898.         fetch_next_i
  5899.         cnop    0,128
  5900.  
  5901. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5902. ;        B9 - CP C - [n = 1, h = x, c = x, z = x]
  5903. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5904.  
  5905. z80_optcode_B9:    move.b    d3,h_other_I
  5906.         subq.l    #1,a5
  5907.         move.b    d1,h_other_II
  5908.         or.w    #$100,d3                ;n = 1!
  5909.  
  5910.         cmp.b    d1,d3
  5911.         move.w    CCR,d4                    ;status updated.
  5912.  
  5913.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  5914.  
  5915.         fetch_next_i
  5916.         cnop    0,128
  5917.  
  5918. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5919. ;        CBB9 - RES 7, C
  5920. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5921.  
  5922. z80_optc_CBB9:    subq.l    #2,a5                    ;less cycles.
  5923.         and.b    #%01111111,d1
  5924.         fetch_next_i
  5925.         cnop    0,128
  5926.  
  5927. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5928. ;        BA - CP D - [n = 1, h = x, c = x, z = x]
  5929. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5930.  
  5931. z80_optcode_BA:    move.b    d3,h_other_I
  5932.         ror.w    #8,d0                    ;d down.
  5933.         move.b    d0,h_other_II
  5934.         subq.l    #1,a5
  5935.  
  5936.         cmp.b    d0,d3
  5937.         move.w    CCR,d4                    ;status updated.
  5938.  
  5939.         rol.w    #8,d0                    ;d back to up.
  5940.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  5941.         or.w    #$100,d3                ;n = 1!
  5942.  
  5943.         fetch_next_i
  5944.         cnop    0,128
  5945.  
  5946. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5947. ;        CBBA - RES 7, D
  5948. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5949.  
  5950. z80_optc_CBBA:    subq.l    #2,a5                    ;less cycles.
  5951.         and.w    #%0111111111111111,d0
  5952.         fetch_next_i
  5953.         cnop    0,128
  5954.  
  5955. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5956. ;        BB - CP E - [n = 1, h = x, c = x, z = x]
  5957. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5958.  
  5959. z80_optcode_BB:    move.b    d0,h_other_II
  5960.         subq.l    #1,a5
  5961.         move.b    d3,h_other_I
  5962.  
  5963.         cmp.b    d0,d3
  5964.         move.w    CCR,d4                    ;status updated.
  5965.  
  5966.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  5967.         or.w    #$100,d3                ;n = 1!
  5968.  
  5969.         fetch_next_i
  5970.         cnop    0,128
  5971.  
  5972. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5973. ;        CBBB - RES 7, E
  5974. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5975.  
  5976. z80_optc_CBBB:    subq.l    #2,a5                    ;less cycles.
  5977.         and.b    #%01111111,d0
  5978.         fetch_next_i
  5979.         cnop    0,128
  5980.  
  5981. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5982. ;        BC - CP H - [n = 1, h = x, c = x, z = x]
  5983. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  5984.  
  5985. z80_optcode_BC:    move.b    d3,h_other_I
  5986.         ror.w    #8,d2                    ;h down.
  5987.         move.b    d2,h_other_II
  5988.         subq.l    #1,a5
  5989.  
  5990.         cmp.b    d2,d3
  5991.         move.w    CCR,d4                    ;status updated.
  5992.  
  5993.         rol.w    #8,d2                    ;h back to up.
  5994.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  5995.         or.w    #$100,d3                ;n = 1!
  5996.  
  5997.         fetch_next_i
  5998.         cnop    0,128
  5999.  
  6000. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6001. ;        CBBC - RES 7, H
  6002. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6003.  
  6004. z80_optc_CBBC:    subq.l    #2,a5                    ;less cycles.
  6005.         and.w    #%0111111111111111,d2
  6006.         fetch_next_i
  6007.         cnop    0,128
  6008.  
  6009. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6010. ;        BD - CP L - [n = 1, h = x, c = x, z = x]
  6011. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6012.  
  6013. z80_optcode_BD:    move.b    d2,h_other_II
  6014.         subq.l    #1,a5
  6015.         move.b    d3,h_other_I
  6016.  
  6017.         cmp.b    d2,d3
  6018.         move.w    CCR,d4                    ;status updated.
  6019.  
  6020.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  6021.         or.w    #$100,d3                ;n = 1!
  6022.  
  6023.         fetch_next_i
  6024.         cnop    0,128
  6025.  
  6026. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6027. ;        CBBD - RES 7, L
  6028. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6029.  
  6030. z80_optc_CBBD:    subq.l    #2,a5                    ;less cycles.
  6031.         and.b    #%01111111,d2
  6032.         fetch_next_i
  6033.         cnop    0,128
  6034.  
  6035. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6036. ;        BE - CP (HL) - [n = 1, h = x, c = x, z = x]
  6037. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6038.  
  6039. z80_optcode_BE:    move.b    d3,h_other_I
  6040.         READ_D2_TO_D6
  6041.         move.b    d6,h_other_II
  6042.         subq.l    #2,a5
  6043.  
  6044.         cmp.b    d6,d3
  6045.         move.w    CCR,d4                    ;status updated.
  6046.  
  6047.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  6048.         or.w    #$100,d3                ;n = 1!
  6049.  
  6050.         fetch_next_i
  6051.         cnop    0,128
  6052.  
  6053. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6054. ;        CBBE - RES 7, (HL)
  6055. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6056.  
  6057. z80_optc_CBBE:    subq.l    #4,a5
  6058.         READ_D2_TO_D6
  6059.         and.b    #%01111111,d6
  6060.         move.w    d2,d7                    ;d7 = a (hl) - write.
  6061.  
  6062.         move.l    gb_mem_jumps,a6
  6063.         jsr    ([a6,d2.l*4])                ;memory write.
  6064.  
  6065.         fetch_next_i
  6066.         cnop    0,128
  6067.  
  6068. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6069. ;        BF - CP A - [n = 1, h = x, c = x, z = x]
  6070. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6071.  
  6072. z80_optcode_BF:    move.b    d3,h_other_I
  6073.         subq.l    #1,a5
  6074.         move.b    d3,h_other_II
  6075.  
  6076.         cmp.b    d3,d3
  6077.         move.w    CCR,d4                    ;status updated.
  6078.  
  6079.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  6080.         or.w    #$100,d3                ;n = 1!
  6081.  
  6082.         fetch_next_i
  6083.         cnop    0,128
  6084.  
  6085. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6086. ;        CBBF - RES 7, A
  6087. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6088.  
  6089. z80_optc_CBBF:    subq.l    #2,a5                    ;less cycles.
  6090.         and.b    #%01111111,d3
  6091.         fetch_next_i
  6092.         cnop    0,128
  6093.  
  6094. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6095. ;        C0 - RET NZ
  6096. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6097.  
  6098. z80_optcode_C0:    subq.l    #2,a5
  6099.  
  6100.         btst    #2,d4                    ;z - flag set?
  6101.         bne.s    z80_cpu_loop_c0                ;yes. it's zero.
  6102.  
  6103.         READW_D5_TO_D7
  6104.         addq.w    #2,d5
  6105.         ror.w    #8,d7
  6106.         blt.s    pc_in_ram_xi
  6107.         move.l    a3,z80_pc_base                ;rom base.
  6108.         lea    (a3,d7.l),a0
  6109.  
  6110. z80_cpu_loop_c0:
  6111.         fetch_next_i
  6112.         cnop    0,4
  6113.  
  6114. pc_in_ram_xi:    move.l    a2,z80_pc_base                ;ram base.
  6115.         lea    (a2,d7.l),a0
  6116.  
  6117.         fetch_next_i
  6118.         cnop    0,128
  6119.  
  6120. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6121. ;        CBC0 - SET 0, B
  6122. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6123.  
  6124. z80_optc_CBC0:    subq.l    #2,a5                    ;less cycles.
  6125.         or.w    #%0000000100000000,d1
  6126.         fetch_next_i
  6127.         cnop    0,128
  6128.  
  6129. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6130. ;        C1 - POP BC
  6131. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6132.  
  6133. z80_optcode_C1:    subq.l    #3,a5
  6134.  
  6135.         tst.w    d5                    ;rom read?
  6136.         blt.s    readw_d5_to_d1a                ;nope. from ram!
  6137.         move.w    (a3,d5.l),d1
  6138.         addq.w    #2,d5                    ;sp = sp + 2.
  6139.         ror.w    #8,d1                    ;order correction.
  6140.  
  6141.         fetch_next_i
  6142.         cnop    0,4
  6143.  
  6144. readw_d5_to_d1a:move.w    (a2,d5.l),d1                ;ram read.
  6145.         addq.w    #2,d5                    ;sp = sp + 2.
  6146.         ror.w    #8,d1                    ;order correction.
  6147.  
  6148.         fetch_next_i
  6149.         cnop    0,128
  6150.  
  6151. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6152. ;        CBC1 - SET 0, C
  6153. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6154.  
  6155. z80_optc_CBC1:    subq.l    #2,a5                    ;less cycles.
  6156.         or.b    #%1,d1
  6157.         fetch_next_i
  6158.         cnop    0,128
  6159.  
  6160. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6161. ;        C2 - JP NZ, xx
  6162. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6163.  
  6164. z80_optcode_C2:    btst    #2,d4                    ;z - flag set?
  6165.         bne.s    z80_optcode_C2x                ;yes. it's zero.
  6166.  
  6167.         move.w    (a0),d7
  6168.         subq.l    #3,a5
  6169.         ror.w    #8,d7                    ;pc updated.
  6170.         blt.s    pc_in_ram_i
  6171.         move.l    a3,z80_pc_base                ;rom base.
  6172.         lea    (a3,d7.l),a0
  6173.  
  6174.         fetch_next_i
  6175.         cnop    0,4
  6176.  
  6177. pc_in_ram_i:    move.l    a2,z80_pc_base                ;ram base.
  6178.         lea    (a2,d7.l),a0
  6179.  
  6180.         fetch_next_i
  6181.         cnop    0,4
  6182.  
  6183. z80_optcode_C2x:addq.l    #2,a0                    ;no jump.
  6184.         subq.l    #3,a5
  6185.  
  6186.         fetch_next_i
  6187.         cnop    0,128
  6188.  
  6189. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6190. ;        CBC2 - SET 0, D
  6191. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6192.  
  6193. z80_optc_CBC2:    subq.l    #2,a5                    ;less cycles.
  6194.         or.w    #%0000000100000000,d0
  6195.         fetch_next_i
  6196.         cnop    0,128
  6197.  
  6198. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6199. ;        C3 - JP xx
  6200. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6201.  
  6202. z80_optcode_C3:    move.w    (a0),d7
  6203.         subq.l    #3,a5
  6204.         ror.w    #8,d7                    ;pc updated.
  6205.         blt.s    pc_in_ram_ii
  6206.         move.l    a3,z80_pc_base                ;rom base.
  6207.         lea    (a3,d7.l),a0
  6208.  
  6209.         fetch_next_i
  6210.         cnop    0,4
  6211.  
  6212. pc_in_ram_ii:    move.l    a2,z80_pc_base                ;ram base.
  6213.         lea    (a2,d7.l),a0
  6214.  
  6215.         fetch_next_i
  6216.         cnop    0,128
  6217.  
  6218. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6219. ;        CBC3 - SET 0, E
  6220. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6221.  
  6222. z80_optc_CBC3:    subq.l    #2,a5                    ;less cycles.
  6223.         or.b    #%1,d0
  6224.         fetch_next_i
  6225.         cnop    0,128
  6226.  
  6227. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6228. ;        C4 - CALL NZ, xx
  6229. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6230.  
  6231. z80_optcode_C4:    btst    #2,d4                    ;z - flag set?
  6232.         bne.s    z80_optcode_C4x                ;yes. it's zero.
  6233.  
  6234.         move.l    a0,d6
  6235.         sub.l    z80_pc_base,d6
  6236.         addq.w    #2,d6
  6237.                 bsr.w   write_d6_stackx
  6238.  
  6239.         move.w    (a0),d7                    ;00BB.
  6240.         subq.l    #3,a5
  6241.         ror.w    #8,d7
  6242.         blt.s    pc_in_ram_vi
  6243.         move.l    a3,z80_pc_base                ;rom base.
  6244.         lea    (a3,d7.l),a0
  6245.  
  6246.         fetch_next_i
  6247.         cnop    0,4
  6248.  
  6249. pc_in_ram_vi:    move.l    a2,z80_pc_base                ;ram base.
  6250.         lea    (a2,d7.l),a0
  6251.  
  6252.         fetch_next_i
  6253.         cnop    0,4
  6254.  
  6255. z80_optcode_C4x:addq.l    #2,a0                    ;no jump.
  6256.         subq.l    #3,a5
  6257.  
  6258.         fetch_next_i
  6259.         cnop    0,128
  6260.  
  6261. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6262. ;        CBC4 - SET 0, H
  6263. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6264.  
  6265. z80_optc_CBC4:    subq.l    #2,a5                    ;less cycles.
  6266.         or.w    #%0000000100000000,d2
  6267.         fetch_next_i
  6268.         cnop    0,128
  6269.  
  6270. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6271. ;        C5 - PUSH BC
  6272. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6273.  
  6274. z80_optcode_C5:    subq.l    #4,a5
  6275.         move.w    d1,d6
  6276.  
  6277.         subq.w    #1,d5
  6278.         move.l    d6,-(SP)
  6279.         move.l    d5,d7
  6280.         move.l    gb_mem_jumps,a6
  6281.         lsr.w    #8,d6                    ;d1 = upper data (h.B).
  6282.         jsr    ([a6,d5.l*4])                ;memory write.
  6283.  
  6284.         move.l    (SP)+,d6
  6285.         subq.w    #1,d5
  6286.         move.l    gb_mem_jumps,a6
  6287.         move.l    d5,d7
  6288.         jsr    ([a6,d5.l*4])                ;memory write.
  6289.  
  6290.         fetch_next_i
  6291.         cnop    0,128
  6292.  
  6293. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6294. ;        CBC5 - SET 0, L
  6295. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6296.  
  6297. z80_optc_CBC5:    subq.l    #2,a5                    ;less cycles.
  6298.         or.b    #%1,d2
  6299.         fetch_next_i
  6300.         cnop    0,128
  6301.  
  6302. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6303. ;        C6 - ADD x - [n = 0, h = x, c = x, z = x]
  6304. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6305.  
  6306. z80_optcode_C6:    move.b    d3,h_other_I
  6307.         subq.l    #2,a5
  6308.         move.b    (a0)+,d7
  6309.         and.w    #$ff,d3                    ;n = 0!
  6310.         move.b    d7,h_other_II
  6311.  
  6312.         add.b    d7,d3                    ;a = a + x.
  6313.         move.w    CCR,d4                    ;status updated.
  6314.  
  6315.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  6316.  
  6317.         fetch_next_i
  6318.         cnop    0,128
  6319.  
  6320. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6321. ;        CBC6 - SET 0, (HL)
  6322. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6323.  
  6324. z80_optc_CBC6:    subq.l    #4,a5
  6325.         move.l    gb_mem_jumps,a6
  6326.  
  6327.         move.w    d2,d7                    ;d7 = a (hl) - write.
  6328.         blt.s    pead_d2_to_d6a
  6329.  
  6330.         move.b    (a3,d2.l),d6                ;rom.
  6331.         or.b    #%1,d6
  6332.         jsr    ([a6,d2.l*4])                ;memory write.
  6333.  
  6334.         fetch_next_i
  6335.         cnop    0,4
  6336.  
  6337. pead_d2_to_d6a:    move.b    (a2,d2.l),d6                ;ram.
  6338.         or.b    #%1,d6
  6339.         jsr    ([a6,d2.l*4])                ;memory write.
  6340.  
  6341.         fetch_next_i
  6342.         cnop    0,128
  6343.  
  6344. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6345. ;        C7 - RST 0
  6346. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6347.  
  6348. z80_optcode_C7:    move.l    a0,d6
  6349.         sub.l    z80_pc_base,d6
  6350.         bsr.w    write_d6_stackx
  6351.  
  6352.         move.l    a3,a0
  6353.         subq.l    #8,a5
  6354.         move.l    a3,z80_pc_base
  6355.  
  6356.         fetch_next_i
  6357.         cnop    0,128
  6358.  
  6359. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6360. ;        CBC7 - SET 0, A
  6361. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6362.  
  6363. z80_optc_CBC7:    subq.l    #2,a5                    ;less cycles.
  6364.         or.b    #%1,d3
  6365.         fetch_next_i
  6366.         cnop    0,128
  6367.  
  6368. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6369. ;        C8 - RET Z
  6370. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6371.  
  6372. z80_optcode_C8:    subq.l    #2,a5
  6373.  
  6374.         btst    #2,d4                    ;z - flag set?
  6375.         beq.s    z80_cpu_loop_c8                ;nope. it's non-zero.
  6376.  
  6377.         READW_D5_TO_D7
  6378.         addq.w    #2,d5
  6379.         ror.w    #8,d7
  6380.         blt.s    pc_in_ram_xii
  6381.         move.l    a3,z80_pc_base                ;rom base.
  6382.         lea    (a3,d7.l),a0
  6383.  
  6384. z80_cpu_loop_c8:
  6385.         fetch_next_i
  6386.         cnop    0,4
  6387.  
  6388. pc_in_ram_xii:    move.l    a2,z80_pc_base                ;ram base.
  6389.         lea    (a2,d7.l),a0
  6390.  
  6391.         fetch_next_i
  6392.         cnop    0,128
  6393.  
  6394. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6395. ;        CBC8 - SET 1, B
  6396. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6397.  
  6398. z80_optc_CBC8:    subq.l    #2,a5                    ;less cycles.
  6399.         or.w    #%0000001000000000,d1
  6400.         fetch_next_i
  6401.         cnop    0,128
  6402.  
  6403. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6404. ;        C9 - RET
  6405. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6406.  
  6407. z80_optcode_C9:
  6408.         READW_D5_TO_D7
  6409.         subq.l    #2,a5                    ;less cycles.
  6410.         addq.w    #2,d5
  6411.         ror.w    #8,d7
  6412.         blt.s    pc_in_ram_xvi
  6413.         move.l    a3,z80_pc_base                ;rom base.
  6414.         lea    (a3,d7.l),a0
  6415.  
  6416.         fetch_next_i
  6417.         cnop    0,4
  6418.  
  6419. pc_in_ram_xvi:    move.l    a2,z80_pc_base                ;ram base.
  6420.         lea    (a2,d7.l),a0
  6421.  
  6422.         fetch_next_i
  6423.         cnop    0,128
  6424.  
  6425. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6426. ;        CBC9 - SET 1, C
  6427. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6428.  
  6429. z80_optc_CBC9:    subq.l    #2,a5                    ;less cycles.
  6430.         or.b    #%10,d1
  6431.         fetch_next_i
  6432.         cnop    0,128
  6433.  
  6434. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6435. ;        CA - JP Z, xx
  6436. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6437.  
  6438. z80_optcode_CA:    btst    #2,d4                    ;z - flag set?
  6439.         beq.s    z80_optcode_CAx                ;nope. it's non-zero.
  6440.  
  6441.         move.w    (a0),d7
  6442.         subq.l    #3,a5
  6443.         ror.w    #8,d7
  6444.         blt.s    pc_in_ram_iii
  6445.         move.l    a3,z80_pc_base                ;rom base.
  6446.         lea    (a3,d7.l),a0
  6447.  
  6448.         fetch_next_i
  6449.         cnop    0,4
  6450.  
  6451. pc_in_ram_iii:    move.l    a2,z80_pc_base                ;ram base.
  6452.         lea    (a2,d7.l),a0
  6453.  
  6454.         fetch_next_i
  6455.         cnop    0,4
  6456.  
  6457. z80_optcode_CAx:addq.l    #2,a0
  6458.         subq.l    #3,a5
  6459.  
  6460.         fetch_next_i
  6461.         cnop    0,128
  6462.  
  6463. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6464. ;        CBCA - SET 1, D
  6465. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6466.  
  6467. z80_optc_CBCA:    subq.l    #2,a5                    ;less cycles.
  6468.         or.w    #%0000001000000000,d0
  6469.         fetch_next_i
  6470.         cnop    0,128
  6471.  
  6472. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6473. ;        CB - RLC, RL, SLA, SRL, BIT, RES and SET
  6474. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6475.  
  6476. z80_optcode_CB:    move.b    (a0)+,d7
  6477.         lsl.w    #8,d7
  6478.         jmp    (a4,d7.l)
  6479.         cnop    0,128
  6480.  
  6481. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6482. ;        CBCB - SET 1, E
  6483. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6484.  
  6485. z80_optc_CBCB:    subq.l    #2,a5                    ;less cycles.
  6486.         or.b    #%10,d0
  6487.         fetch_next_i
  6488.         cnop    0,128
  6489.  
  6490. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6491. ;        CC - CALL Z, xx
  6492. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6493.  
  6494. z80_optcode_CC:    btst    #2,d4                    ;z - flag set?
  6495.         beq.s    z80_optcode_CCx                ;nope. it's non-zero.
  6496.  
  6497.         move.l    a0,d6
  6498.         sub.l    z80_pc_base,d6
  6499.         addq.w    #2,d6
  6500.                 bsr.w   write_d6_stackx
  6501.  
  6502.         move.w    (a0),d7                    ;00BB.
  6503.         subq.l    #3,a5
  6504.         ror.w    #8,d7                    ;pc updated.
  6505.         blt.s    pc_in_ram_vii
  6506.         move.l    a3,z80_pc_base                ;rom base.
  6507.         lea    (a3,d7.l),a0
  6508.  
  6509.         fetch_next_i
  6510.         cnop    0,4
  6511.  
  6512. pc_in_ram_vii:    move.l    a2,z80_pc_base                ;ram base.
  6513.         lea    (a2,d7.l),a0
  6514.  
  6515.         fetch_next_i
  6516.         cnop    0,4
  6517.  
  6518. z80_optcode_CCx:addq.l    #2,a0                    ;no jump.
  6519.         subq.l    #3,a5
  6520.  
  6521.         fetch_next_i
  6522.         cnop    0,128
  6523.  
  6524. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6525. ;        CBCC - SET 1, H
  6526. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6527.  
  6528. z80_optc_CBCC:    subq.l    #2,a5                    ;less cycles.
  6529.         or.w    #%0000001000000000,d2
  6530.         fetch_next_i
  6531.         cnop    0,128
  6532.  
  6533. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6534. ;        CD - CALL xx
  6535. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6536.  
  6537. z80_optcode_CD:    move.l    a0,d6
  6538.         sub.l    z80_pc_base,d6
  6539.         addq.w    #2,d6
  6540.                 bsr.w   write_d6_stackx
  6541.  
  6542.         move.w    (a0),d7                    ;00BB.
  6543.         subq.l    #3,a5
  6544.         ror.w    #8,d7
  6545.         blt.s    pc_in_ram_viii
  6546.         move.l    a3,z80_pc_base                ;rom base.
  6547.         lea    (a3,d7.l),a0
  6548.  
  6549.         fetch_next_i
  6550.         cnop    0,4
  6551.  
  6552. pc_in_ram_viii:    move.l    a2,z80_pc_base                ;ram base.
  6553.         lea    (a2,d7.l),a0
  6554.  
  6555.         fetch_next_i
  6556.         cnop    0,128
  6557.  
  6558. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6559. ;        CBCD - SET 1, L
  6560. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6561.  
  6562. z80_optc_CBCD:    subq.l    #2,a5                    ;less cycles.
  6563.         or.b    #%10,d2
  6564.         fetch_next_i
  6565.         cnop    0,128
  6566.  
  6567. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6568. ;        CE - ADC x - [n = 0, h = x, c = x, z = x]
  6569. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6570.  
  6571. z80_optcode_CE:    btst    #0,d4                    ;c = 0?
  6572.         beq.w    z80_optcode_C6                ;yes. normal add.
  6573.  
  6574.         move.b    (a0)+,d6
  6575.         move.b    d3,h_other_I
  6576.         subq.l    #2,a5                    ;less cycles.
  6577.         and.w    #$ff,d3                    ;n = 0!
  6578.         move.b    d6,h_other_II
  6579.  
  6580.         move.w    #%10000,CCR                ;x = 1!
  6581.         addx.b    d6,d3                    ;a = a + c + c.
  6582.         move.w    CCR,d4                    ;status updated.
  6583.  
  6584.         move.w    #$0102,h_with_carry            ;yes carry! h = x!
  6585.  
  6586.         fetch_next_i
  6587.         cnop    0,128
  6588.  
  6589. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6590. ;        CBCE - SET 1, (HL)
  6591. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6592.  
  6593. z80_optc_CBCE:    subq.l    #4,a5
  6594.         move.l    gb_mem_jumps,a6
  6595.  
  6596.         move.w    d2,d7                    ;d7 = a (hl) - write.
  6597.         blt.s    lead_d2_to_d6a
  6598.  
  6599.         move.b    (a3,d2.l),d6
  6600.         or.b    #%10,d6
  6601.         jsr    ([a6,d2.l*4])                ;memory write.
  6602.  
  6603.         fetch_next_i
  6604.         cnop    0,4
  6605.  
  6606. lead_d2_to_d6a:    move.b    (a2,d2.l),d6                ;ram.
  6607.         or.b    #%10,d6
  6608.         jsr    ([a6,d2.l*4])                ;memory write.
  6609.  
  6610.         fetch_next_i
  6611.         cnop    0,128
  6612.  
  6613. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6614. ;        CF - RST 8
  6615. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6616.  
  6617. z80_optcode_CF:    move.l    a0,d6
  6618.         sub.l    z80_pc_base,d6
  6619.         bsr.w    write_d6_stackx
  6620.  
  6621.         lea    $8(a3),a0
  6622.         subq.l    #8,a5
  6623.         move.l    a3,z80_pc_base
  6624.  
  6625.         fetch_next_i
  6626.         cnop    0,128
  6627.  
  6628. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6629. ;        CBCF - SET 1, A
  6630. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6631.  
  6632. z80_optc_CBCF:    subq.l    #2,a5                    ;less cycles.
  6633.         or.b    #%10,d3
  6634.         fetch_next_i
  6635.         cnop    0,128
  6636.  
  6637. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6638. ;        D0 - RET NC
  6639. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6640.  
  6641. z80_optcode_D0:    subq.l    #2,a5
  6642.  
  6643.         btst    #0,d4                    ;c - flag set?
  6644.         bne.s    z80_cpu_loop_d0                ;yes. no jump.
  6645.  
  6646.         READW_D5_TO_D7
  6647.         addq.w    #2,d5
  6648.         ror.w    #8,d7
  6649.         blt.s    pc_in_ram_xiii
  6650.         move.l    a3,z80_pc_base                ;rom base.
  6651.         lea    (a3,d7.l),a0
  6652.  
  6653. z80_cpu_loop_d0:
  6654.         fetch_next_i
  6655.         cnop    0,4
  6656.  
  6657. pc_in_ram_xiii:    move.l    a2,z80_pc_base                ;ram base.
  6658.         lea    (a2,d7.l),a0
  6659.  
  6660.         fetch_next_i
  6661.         cnop    0,128
  6662.  
  6663. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6664. ;        CBD0 - SET 2, B
  6665. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6666.  
  6667. z80_optc_CBD0:    subq.l    #2,a5                    ;less cycles.
  6668.         or.w    #%0000010000000000,d1
  6669.         fetch_next_i
  6670.         cnop    0,128
  6671.  
  6672. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6673. ;        D1 - POP DE
  6674. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6675.  
  6676. z80_optcode_D1:    subq.l    #3,a5
  6677.  
  6678.         tst.w    d5                    ;rom read?
  6679.         blt.s    readw_d5_to_d0a                ;nope. from ram!
  6680.         move.w    (a3,d5.l),d0
  6681.         addq.w    #2,d5                    ;sp = sp + 2.
  6682.         ror.w    #8,d0                    ;order correction.
  6683.  
  6684.         fetch_next_i
  6685.         cnop    0,4
  6686.  
  6687. readw_d5_to_d0a:move.w    (a2,d5.l),d0                ;ram read.
  6688.         addq.w    #2,d5                    ;sp = sp + 2.
  6689.         ror.w    #8,d0                    ;order correction.
  6690.  
  6691.         fetch_next_i
  6692.         cnop    0,128
  6693.  
  6694. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6695. ;        CBD1 - SET 2, C
  6696. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6697.  
  6698. z80_optc_CBD1:    subq.l    #2,a5                    ;less cycles.
  6699.         or.b    #%100,d1
  6700.         fetch_next_i
  6701.         cnop    0,128
  6702.  
  6703. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6704. ;        D2 - JP NC, xx
  6705. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6706.  
  6707. z80_optcode_D2:    btst    #0,d4                    ;c - flag set?
  6708.         bne.s    z80_optcode_D2x                ;yes. no jump.
  6709.  
  6710.         move.w    (a0),d7
  6711.         subq.l    #3,a5
  6712.         ror.w    #8,d7
  6713.         blt.s    pc_in_ram_iv
  6714.         move.l    a3,z80_pc_base                ;rom base.
  6715.         lea    (a3,d7.l),a0
  6716.  
  6717.         fetch_next_i
  6718.         cnop    0,4
  6719.  
  6720. pc_in_ram_iv:    move.l    a2,z80_pc_base                ;ram base.
  6721.         lea    (a2,d7.l),a0
  6722.  
  6723.         fetch_next_i
  6724.         cnop    0,4
  6725.  
  6726. z80_optcode_D2x:addq.l    #2,a0                    ;no jump.
  6727.         subq.l    #3,a5
  6728.  
  6729.         fetch_next_i
  6730.         cnop    0,128
  6731.  
  6732. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6733. ;        CBD2 - SET 2, D
  6734. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6735.  
  6736. z80_optc_CBD2:    subq.l    #2,a5                    ;less cycles.
  6737.         or.w    #%0000010000000000,d0
  6738.         fetch_next_i
  6739.         cnop    0,128
  6740.  
  6741. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6742. ;        D3 - DB $D3 ???
  6743. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6744.  
  6745. z80_optcode_D3:    fetch_next_i
  6746.         cnop    0,128
  6747.  
  6748. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6749. ;        CBD3 - SET 2, E
  6750. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6751.  
  6752. z80_optc_CBD3:    subq.l    #2,a5                    ;less cycles.
  6753.         or.b    #%100,d0
  6754.         fetch_next_i
  6755.         cnop    0,128
  6756.  
  6757. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6758. ;        D4 - CALL NC, xx
  6759. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6760.  
  6761. z80_optcode_D4:    btst    #0,d4                    ;c - flag set?
  6762.         bne.s    z80_optcode_D4x                ;yes. no jump.
  6763.  
  6764.         move.l    a0,d6
  6765.         sub.l    z80_pc_base,d6
  6766.         addq.w    #2,d6
  6767.         bsr.w    write_d6_stackx
  6768.  
  6769.         move.w    (a0),d7                    ;00BB.
  6770.         subq.l    #3,a5
  6771.         ror.w    #8,d7
  6772.         blt.s    pc_in_ram_ix
  6773.         move.l    a3,z80_pc_base                ;rom base.
  6774.         lea    (a3,d7.l),a0
  6775.  
  6776.         fetch_next_i
  6777.         cnop    0,4
  6778.  
  6779. pc_in_ram_ix:    move.l    a2,z80_pc_base                ;ram base.
  6780.         lea    (a2,d7.l),a0
  6781.  
  6782.         fetch_next_i
  6783.         cnop    0,4
  6784.  
  6785. z80_optcode_D4x:addq.l    #2,a0                    ;no jump.
  6786.         subq.l    #3,a5
  6787.  
  6788.         fetch_next_i
  6789.         cnop    0,128
  6790.  
  6791. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6792. ;        CBD4 - SET 2, H
  6793. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6794.  
  6795. z80_optc_CBD4:    subq.l    #2,a5                    ;less cycles.
  6796.         or.w    #%0000010000000000,d2
  6797.         fetch_next_i
  6798.         cnop    0,128
  6799.  
  6800. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6801. ;        D5 - PUSH DE
  6802. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6803.  
  6804. z80_optcode_D5:    move.w    d0,d6
  6805.         subq.l    #4,a5
  6806.  
  6807.         subq.w    #1,d5
  6808.         move.l    d6,-(SP)
  6809.         lsr.w    #8,d6                    ;d6 = upper data (h.B).
  6810.         move.l    gb_mem_jumps,a6
  6811.         move.l    d5,d7
  6812.         jsr    ([a6,d5.l*4])                ;memory write.
  6813.  
  6814.         move.l    (SP)+,d6
  6815.         subq.w    #1,d5
  6816.         move.l    gb_mem_jumps,a6
  6817.         move.l    d5,d7
  6818.         jsr    ([a6,d5.l*4])                ;memory write.
  6819.  
  6820.         fetch_next_i
  6821.         cnop    0,128
  6822.  
  6823. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6824. ;        CBD5 - SET 2, L
  6825. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6826.  
  6827. z80_optc_CBD5:    subq.l    #2,a5                    ;less cycles.
  6828.         or.b    #%100,d2
  6829.         fetch_next_i
  6830.         cnop    0,128
  6831.  
  6832. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6833. ;        D6 - SUB x - [n = 1, h = x, c = x, z = x]
  6834. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6835.  
  6836. z80_optcode_D6:    move.b    (a0)+,d7
  6837.  
  6838.         move.b    d3,h_other_I
  6839.         subq.l    #2,a5                    ;less cycles.
  6840.         or.w    #$100,d3                ;n = 1!
  6841.         move.b    d7,h_other_II
  6842.  
  6843.         sub.b    d7,d3                    ;a = a - x.
  6844.         move.w    CCR,d4                    ;status updated.
  6845.  
  6846.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  6847.  
  6848.         fetch_next_i
  6849.         cnop    0,128
  6850.  
  6851. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6852. ;        CBD6 - SET 2, (HL)
  6853. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6854.  
  6855. z80_optc_CBD6:    subq.l    #4,a5
  6856.         move.l    gb_mem_jumps,a6
  6857.  
  6858.         move.w    d2,d7                    ;d7 = a (hl) - write.
  6859.         blt.s    aead_d2_to_d6a
  6860.  
  6861.         move.b    (a3,d2.l),d6
  6862.         or.b    #%100,d6
  6863.         jsr    ([a6,d2.l*4])                ;memory write.
  6864.  
  6865.         fetch_next_i
  6866.         cnop    0,4
  6867.  
  6868. aead_d2_to_d6a:    move.b    (a2,d2.l),d6                ;ram.
  6869.         or.b    #%100,d6
  6870.         jsr    ([a6,d2.l*4])                ;memory write.
  6871.  
  6872.         fetch_next_i
  6873.         cnop    0,128
  6874.  
  6875. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6876. ;        D7 - RST 10h
  6877. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6878.  
  6879. z80_optcode_D7:    move.l    a0,d6
  6880.         sub.l    z80_pc_base,d6
  6881.         bsr.w    write_d6_stackx
  6882.  
  6883.         lea    $10(a3),a0
  6884.         subq.l    #8,a5
  6885.         move.l    a3,z80_pc_base
  6886.  
  6887.         fetch_next_i
  6888.         cnop    0,128
  6889.  
  6890. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6891. ;        CBD7 - SET 2, A
  6892. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6893.  
  6894. z80_optc_CBD7:    subq.l    #2,a5                    ;less cycles.
  6895.         or.b    #%100,d3
  6896.         fetch_next_i
  6897.         cnop    0,128
  6898.  
  6899. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6900. ;        D8 - RET C
  6901. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6902.  
  6903. z80_optcode_D8:    subq.l    #2,a5
  6904.  
  6905.         btst    #0,d4                    ;c - flag set?
  6906.         beq.s    z80_cpu_loop_d8                ;no. no return.
  6907.  
  6908.         READW_D5_TO_D7
  6909.         addq.w    #2,d5
  6910.         ror.w    #8,d7
  6911.         blt.s    pc_in_ram_xiv
  6912.         move.l    a3,z80_pc_base                ;rom base.
  6913.         lea    (a3,d7.l),a0
  6914.  
  6915. z80_cpu_loop_d8:
  6916.         fetch_next_i
  6917.         cnop    0,4
  6918.  
  6919. pc_in_ram_xiv:    move.l    a2,z80_pc_base                ;ram base.
  6920.         lea    (a2,d7.l),a0
  6921.  
  6922.         fetch_next_i
  6923.         cnop    0,128
  6924.  
  6925. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6926. ;        CBD8 - SET 3, B
  6927. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6928.  
  6929. z80_optc_CBD8:    subq.l    #2,a5                    ;less cycles.
  6930.         or.w    #%0000100000000000,d1
  6931.         fetch_next_i
  6932.         cnop    0,128
  6933.  
  6934. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6935. ;        D9 - RETI
  6936. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6937.  
  6938. z80_optcode_D9:    subq.l    #2,a5                    ;less cycles.
  6939.         clr.b    i_flag                    ;enable interrupts.
  6940.  
  6941.         READW_D5_TO_D7
  6942.         addq.w    #2,d5
  6943.         ror.w    #8,d7
  6944.         blt.s    pc_in_ram_xv
  6945.         move.l    a3,z80_pc_base                ;rom base.
  6946.         lea    (a3,d7.l),a0
  6947.  
  6948.         bra.w    reti_back
  6949.         cnop    0,4
  6950.  
  6951. pc_in_ram_xv:    move.l    a2,z80_pc_base                ;ram base.
  6952.         lea    (a2,d7.l),a0
  6953.  
  6954.         bra.w    reti_back
  6955.         cnop    0,128
  6956.  
  6957. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6958. ;        CBD9 - SET 3, C
  6959. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6960.  
  6961. z80_optc_CBD9:    subq.l    #2,a5                    ;less cycles.
  6962.         or.b    #%1000,d1
  6963.         fetch_next_i
  6964.         cnop    0,128
  6965.  
  6966. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6967. ;        DA - JP C, xx
  6968. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6969.  
  6970. z80_optcode_DA:    btst    #0,d4                    ;c - flag set?
  6971.         beq.s    z80_optcode_DAx                ;no. no jump.
  6972.  
  6973.         move.w    (a0),d7
  6974.         subq.l    #3,a5
  6975.         ror.w    #8,d7                    ;pc updated.
  6976.         blt.s    pc_in_ram_v
  6977.         move.l    a3,z80_pc_base                ;rom base.
  6978.         lea    (a3,d7.l),a0
  6979.  
  6980.         fetch_next_i
  6981.         cnop    0,4
  6982.  
  6983. pc_in_ram_v:    move.l    a2,z80_pc_base                ;ram base.
  6984.         lea    (a2,d7.l),a0
  6985.  
  6986.         fetch_next_i
  6987.         cnop    0,4
  6988.  
  6989. z80_optcode_DAx:addq.l    #2,a0                    ;no jump.
  6990.         subq.l    #3,a5
  6991.  
  6992.         fetch_next_i
  6993.         cnop    0,128
  6994.  
  6995. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6996. ;        CBDA - SET 3, D
  6997. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  6998.  
  6999. z80_optc_CBDA:    subq.l    #2,a5                    ;less cycles.
  7000.         or.w    #%0000100000000000,d0
  7001.         fetch_next_i
  7002.         cnop    0,128
  7003.  
  7004. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7005. ;        DB - DB $DB ???
  7006. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7007.  
  7008. z80_optcode_DB:    fetch_next_i
  7009.         cnop    0,128
  7010.  
  7011. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7012. ;        CBDB - SET 3, E
  7013. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7014.  
  7015. z80_optc_CBDB:    subq.l    #2,a5                    ;less cycles.
  7016.         or.b    #%1000,d0
  7017.         fetch_next_i
  7018.         cnop    0,128
  7019.  
  7020. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7021. ;        DC - CALL C, xx
  7022. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7023.  
  7024. z80_optcode_DC:    btst    #0,d4                    ;c - flag set?
  7025.         beq.s    z80_optcode_DCx                ;no. no jump.
  7026.  
  7027.         move.l    a0,d6
  7028.         sub.l    z80_pc_base,d6
  7029.         addq.w    #2,d6
  7030.         bsr.w    write_d6_stackx
  7031.  
  7032.         move.w    (a0),d7                    ;00BB.
  7033.         subq.l    #3,a5
  7034.         ror.w    #8,d7
  7035.         blt.s    pc_in_ram_x
  7036.         move.l    a3,z80_pc_base                ;rom base.
  7037.         lea    (a3,d7.l),a0
  7038.  
  7039.         fetch_next_i
  7040.         cnop    0,4
  7041.  
  7042. pc_in_ram_x:    move.l    a2,z80_pc_base                ;ram base.
  7043.         lea    (a2,d7.l),a0
  7044.  
  7045.         fetch_next_i
  7046.         cnop    0,4
  7047.  
  7048. z80_optcode_DCx:addq.l    #2,a0                    ;no jump.
  7049.         subq.l    #3,a5
  7050.  
  7051.         fetch_next_i
  7052.         cnop    0,128
  7053.  
  7054. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7055. ;        CBDC - SET 3, H
  7056. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7057.  
  7058. z80_optc_CBDC:    subq.l    #2,a5                    ;less cycles.
  7059.         or.w    #%0000100000000000,d2
  7060.         fetch_next_i
  7061.         cnop    0,128
  7062.  
  7063. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7064. ;        DD - DB $DD
  7065. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7066.  
  7067. z80_optcode_DD:    fetch_next_i
  7068.         cnop    0,128
  7069.  
  7070. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7071. ;        CBDD - SET 3, L
  7072. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7073.  
  7074. z80_optc_CBDD:    subq.l    #2,a5                    ;less cycles.
  7075.         or.b    #%1000,d2
  7076.         fetch_next_i
  7077.         cnop    0,128
  7078.  
  7079. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7080. ;        DE - SBC x - [n = 1, h = x, c = x, z = x]
  7081. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7082.  
  7083. z80_optcode_DE:    btst    #0,d4                    ;c = 0?
  7084.         beq.w    z80_optcode_D6                ;yes. normal sub.
  7085.  
  7086.         move.b    (a0)+,d6
  7087.         move.b    d3,h_other_I
  7088.         subq.l    #2,a5                    ;less cycles.
  7089.         or.w    #$100,d3                ;n = 1!
  7090.         move.b    d6,h_other_II
  7091.  
  7092.         move.w    #%10000,CCR                ;x = 1!
  7093.         subx.b    d6,d3                    ;a = a - d - c.
  7094.         move.w    CCR,d4                    ;status updated.
  7095.  
  7096.         move.w    #$0102,h_with_carry            ;yes carry! h = x!
  7097.  
  7098.         fetch_next_i
  7099.         cnop    0,128
  7100.  
  7101. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7102. ;        CBDE - SET 3, (HL)
  7103. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7104.  
  7105. z80_optc_CBDE:    subq.l    #4,a5
  7106.         move.l    gb_mem_jumps,a6
  7107.  
  7108.         move.w    d2,d7                    ;d7 = a (hl) - write.
  7109.         blt.s    qead_d2_to_d6a
  7110.  
  7111.         move.b    (a3,d2.l),d6
  7112.         or.b    #%1000,d6
  7113.         jsr    ([a6,d2.l*4])                ;memory write.
  7114.  
  7115.         fetch_next_i
  7116.         cnop    0,4
  7117.  
  7118. qead_d2_to_d6a:    move.b    (a2,d2.l),d6                ;ram read.
  7119.         or.b    #%1000,d6
  7120.         jsr    ([a6,d2.l*4])                ;memory write.
  7121.  
  7122.         fetch_next_i
  7123.         cnop    0,128
  7124.  
  7125. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7126. ;        DF - RST 18h
  7127. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7128.  
  7129. z80_optcode_DF:    move.l    a0,d6
  7130.         sub.l    z80_pc_base,d6
  7131.         bsr.l    write_d6_stackx
  7132.  
  7133.         lea    $18(a3),a0
  7134.         subq.l    #8,a5
  7135.         move.l    a3,z80_pc_base
  7136.  
  7137.         fetch_next_i
  7138.         cnop    0,128
  7139.  
  7140. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7141. ;        CBDF - SET 3, A
  7142. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7143.  
  7144. z80_optc_CBDF:    subq.l    #2,a5                    ;less cycles.
  7145.         or.b    #%1000,d3
  7146.         fetch_next_i
  7147.         cnop    0,128
  7148.  
  7149. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7150. ;        E0 - LD ($FF00+x), A
  7151. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7152.  
  7153. z80_optcode_E0:    move.w    #$ff00,d7                ;custom registers.
  7154.         subq.l    #3,a5
  7155.         move.b    (a0)+,d7
  7156.         move.b    d3,d6                    ;d6 = a.
  7157.  
  7158.         move.l    gb_mem_jumps,a6
  7159.         jsr    ([a6,d7.l*4])                ;memory write.
  7160.  
  7161.         fetch_next_i
  7162.         cnop    0,128
  7163.  
  7164. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7165. ;        CBE0 - SET 4, B
  7166. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7167.  
  7168. z80_optc_CBE0:    subq.l    #2,a5                    ;less cycles.
  7169.         or.w    #%0001000000000000,d1
  7170.         fetch_next_i
  7171.         cnop    0,128
  7172.  
  7173. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7174. ;        E1 - POP HL
  7175. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7176.  
  7177. z80_optcode_E1:    subq.l    #3,a5
  7178.  
  7179.         tst.w    d5                    ;rom read?
  7180.         blt.s    readw_d5_to_d2a                ;nope. from ram!
  7181.         move.w    (a3,d5.l),d2
  7182.         ror.w    #8,d2                    ;order correction.
  7183.         addq.w    #2,d5                    ;sp = sp + 2.
  7184.  
  7185.         fetch_next_i
  7186.         cnop    0,4
  7187.  
  7188. readw_d5_to_d2a:move.w    (a2,d5.l),d2                ;ram read.
  7189.         ror.w    #8,d2                    ;order correction.
  7190.         addq.w    #2,d5                    ;sp = sp + 2.
  7191.  
  7192.         fetch_next_i
  7193.         cnop    0,128
  7194.  
  7195. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7196. ;        CBE1 - SET 4, C
  7197. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7198.  
  7199. z80_optc_CBE1:    subq.l    #2,a5                    ;less cycles.
  7200.         or.b    #%10000,d1
  7201.         fetch_next_i
  7202.         cnop    0,128
  7203.  
  7204. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7205. ;        E2 - LD ($FF00+C), A
  7206. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7207.  
  7208. z80_optcode_E2:    move.w    #$ff00,d7                ;custom registers.
  7209.         subq.l    #2,a5                    ;less cycles.
  7210.         move.b    d1,d7                    ;offset.
  7211.         move.b    d3,d6                    ;d6 = a.
  7212.  
  7213.         move.l    gb_mem_jumps,a6
  7214.         jsr    ([a6,d7.l*4])                ;memory write.
  7215.  
  7216.         fetch_next_i
  7217.         cnop    0,128
  7218.  
  7219. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7220. ;        CBE2 - SET 4, D
  7221. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7222.  
  7223. z80_optc_CBE2:    subq.l    #2,a5                    ;less cycles.
  7224.         or.w    #%0001000000000000,d0
  7225.         fetch_next_i
  7226.         cnop    0,128
  7227.  
  7228. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7229. ;        E3 - EX HL, (SP) ???
  7230. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7231.  
  7232. z80_optcode_E3:
  7233.         READW_D5_TO_D7
  7234.  
  7235.         move.l    d7,-(SP)
  7236.         move.w    d5,d7                    ;d7 = stack address.
  7237.         move.b    d2,d6                    ;d6 = l.B.
  7238.  
  7239.         move.l    gb_mem_jumps,a6
  7240.         jsr    ([a6,d7.l*4])                ;memory write.
  7241.  
  7242.         lsr.w    #8,d2                    ;d2 = h.B.
  7243.         move.w    d5,d7                    ;d7 = stack address +1.
  7244.         move.b    d2,d6
  7245.         addq.w    #1,d7
  7246.  
  7247.         move.l    gb_mem_jumps,a6
  7248.         jsr    ([a6,d7.l*4])                ;memory write.
  7249.  
  7250.         move.l    (SP)+,d7
  7251.  
  7252.         move.w    d7,d2
  7253.         ror.w    #8,d2
  7254.  
  7255.         fetch_next_i
  7256.         cnop    0,128
  7257.  
  7258. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7259. ;        CBE3 - SET 4, E
  7260. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7261.  
  7262. z80_optc_CBE3:    subq.l    #2,a5                    ;less cycles.
  7263.         or.b    #%10000,d0
  7264.         fetch_next_i
  7265.         cnop    0,128
  7266.  
  7267. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7268. ;        E4 - DB $E4 ???
  7269. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7270.  
  7271. z80_optcode_E4:    fetch_next_i
  7272.         cnop    0,128
  7273.  
  7274. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7275. ;        CBE4 - SET 4, H
  7276. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7277.  
  7278. z80_optc_CBE4:    subq.l    #2,a5                    ;less cycles.
  7279.         or.w    #%0001000000000000,d2
  7280.         fetch_next_i
  7281.         cnop    0,128
  7282.  
  7283. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7284. ;        E5 - PUSH HL
  7285. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7286.  
  7287. z80_optcode_E5:    move.w    d2,d6
  7288.         subq.l    #4,a5
  7289.  
  7290.         subq.w    #1,d5
  7291.         move.l    d6,-(SP)
  7292.         lsr.w    #8,d6                    ;d6 = upper data (h.B).
  7293.         move.l    gb_mem_jumps,a6
  7294.         move.l    d5,d7
  7295.         jsr    ([a6,d5.l*4])                ;memory write.
  7296.  
  7297.         move.l    (SP)+,d6
  7298.         subq.w    #1,d5
  7299.         move.l    gb_mem_jumps,a6
  7300.         move.l    d5,d7
  7301.         jsr    ([a6,d5.l*4])                ;memory write.
  7302.  
  7303.         fetch_next_i
  7304.         cnop    0,128
  7305.  
  7306. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7307. ;        CBE5 - SET 4, L
  7308. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7309.  
  7310. z80_optc_CBE5:    subq.l    #2,a5                    ;less cycles.
  7311.         or.b    #%10000,d2
  7312.         fetch_next_i
  7313.         cnop    0,128
  7314.  
  7315. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7316. ;        E6 - AND x - [n = 0, h = 1, c = 0, z = x]
  7317. ;        MC680x0 CLEARS THE CARRY FLAG ITSELF!
  7318. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7319.  
  7320. z80_optcode_E6:    move.b    (a0)+,d7
  7321.         subq.l    #2,a5                    ;less cycles.
  7322.         and.b    d7,d3
  7323.         move.w    CCR,d4                    ;status updated.
  7324.  
  7325.         move.l    #$00000001,h_other_I            ;h = 1! no carry!
  7326.         and.w    #$ff,d3                    ;n = 0!
  7327.  
  7328.         fetch_next_i
  7329.         cnop    0,128
  7330.  
  7331. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7332. ;        CBE6 - SET 4, (HL)
  7333. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7334.  
  7335. z80_optc_CBE6:    subq.l    #4,a5
  7336.         move.l    gb_mem_jumps,a6
  7337.  
  7338.         move.w    d2,d7                    ;d7 = a (hl) - write.
  7339.         blt.s    wead_d2_to_d6a
  7340.  
  7341.         move.b    (a3,d2.l),d6
  7342.         or.b    #%10000,d6
  7343.         jsr    ([a6,d2.l*4])                ;memory write.
  7344.  
  7345.         fetch_next_i
  7346.         cnop    0,4
  7347.  
  7348. wead_d2_to_d6a:    move.b    (a2,d2.l),d6                ;ram read.
  7349.         or.b    #%10000,d6
  7350.         jsr    ([a6,d2.l*4])                ;memory write.
  7351.  
  7352.         fetch_next_i
  7353.         cnop    0,128
  7354.  
  7355. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7356. ;        E7 - RST 20h
  7357. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7358.  
  7359. z80_optcode_E7:    move.l    a0,d6
  7360.         sub.l    z80_pc_base,d6
  7361.         bsr.l    write_d6_stackx
  7362.  
  7363.         lea    $20(a3),a0
  7364.         subq.l    #8,a5
  7365.         move.l    a3,z80_pc_base
  7366.  
  7367.         fetch_next_i
  7368.         cnop    0,128
  7369.  
  7370. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7371. ;        CBE7 - SET 4, A
  7372. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7373.  
  7374. z80_optc_CBE7:    subq.l    #2,a5                    ;less cycles.
  7375.         or.b    #%10000,d3
  7376.         fetch_next_i
  7377.         cnop    0,128
  7378.  
  7379. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7380. ;        E8 - ADD SP, x - [n = 0, h = x, c = x, z = 0]
  7381. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7382.  
  7383. z80_optcode_E8:    move.b    (a0)+,d7                ;no h emulation
  7384.         ext.w    d7                    ;for this optcode.
  7385.         subq.l    #4,a5
  7386.         add.w    d7,d5
  7387.         move.w    CCR,d4
  7388.         and.w    #$ff,d3                    ;n = 0.
  7389.         and.b    #%1,d4
  7390.  
  7391.         fetch_next_i
  7392.         cnop    0,128
  7393.  
  7394. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7395. ;        CBE8 - SET 5, B
  7396. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7397.  
  7398. z80_optc_CBE8:    subq.l    #2,a5                    ;less cycles.
  7399.         or.w    #%0010000000000000,d1
  7400.         fetch_next_i
  7401.         cnop    0,128
  7402.  
  7403. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7404. ;        E9 - LD PC, HL
  7405. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7406.  
  7407. z80_optcode_E9:    subq.l    #1,a5                    ;less cycles.
  7408.  
  7409.         tst.w    d2
  7410.         blt.s    pc_in_ram_xvii
  7411.         move.l    a3,z80_pc_base                ;rom base.
  7412.         lea    (a3,d2.l),a0
  7413.  
  7414.         fetch_next_i
  7415.         cnop    0,4
  7416.  
  7417. pc_in_ram_xvii:    move.l    a2,z80_pc_base                ;ram base.
  7418.         lea    (a2,d2.l),a0
  7419.  
  7420.         fetch_next_i
  7421.         cnop    0,128
  7422.  
  7423. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7424. ;        CBE9 - SET 5, C
  7425. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7426.  
  7427. z80_optc_CBE9:    subq.l    #2,a5                    ;less cycles.
  7428.         or.b    #%100000,d1
  7429.         fetch_next_i
  7430.         cnop    0,128
  7431.  
  7432. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7433. ;        EA - LD (xx), A
  7434. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7435.  
  7436. z80_optcode_EA:    move.w    (a0)+,d7
  7437.         subq.l    #4,a5
  7438.         ror.w    #8,d7
  7439.         move.b    d3,d6                    ;d6 = a.
  7440.  
  7441.         move.l    gb_mem_jumps,a6
  7442.         jsr    ([a6,d7.l*4])                ;memory write.
  7443.  
  7444.         fetch_next_i
  7445.         cnop    0,128
  7446.  
  7447. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7448. ;        CBEA - SET 5, D
  7449. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7450.  
  7451. z80_optc_CBEA:    subq.l    #2,a5                    ;less cycles.
  7452.         or.w    #%0010000000000000,d0
  7453.         fetch_next_i
  7454.         cnop    0,128
  7455.  
  7456. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7457. ;        EB - DB $EB ???
  7458. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7459.  
  7460. z80_optcode_EB:    fetch_next_i
  7461.         cnop    0,128
  7462.  
  7463. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7464. ;        CBEB - SET 5, E
  7465. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7466.  
  7467. z80_optc_CBEB:    subq.l    #2,a5                    ;less cycles.
  7468.         or.b    #%100000,d0
  7469.         fetch_next_i
  7470.         cnop    0,128
  7471.  
  7472. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7473. ;        EC - DB $EC ???
  7474. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7475.  
  7476. z80_optcode_EC:    fetch_next_i
  7477.         cnop    0,128
  7478.  
  7479. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7480. ;        CBEC - SET 5, H
  7481. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7482.  
  7483. z80_optc_CBEC:    subq.l    #2,a5                    ;less cycles.
  7484.         or.w    #%0010000000000000,d2
  7485.         fetch_next_i
  7486.         cnop    0,128
  7487.  
  7488. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7489. ;        ED - PREFIX $ED ???
  7490. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7491.  
  7492. z80_optcode_ED:    bchg.b    #1,$bfe001
  7493.         fetch_next_i
  7494.         cnop    0,128
  7495.  
  7496. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7497. ;        CBED - SET 5, L
  7498. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7499.  
  7500. z80_optc_CBED:    subq.l    #2,a5                    ;less cycles.
  7501.         or.b    #%100000,d2
  7502.         fetch_next_i
  7503.         cnop    0,128
  7504.  
  7505. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7506. ;        EE - XOR x - [n = 0, h = 0, c = 0, z = x]
  7507. ;        MC680x0 CLEARS THE CARRY FLAG ITSELF!
  7508. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7509.  
  7510. z80_optcode_EE:    move.b    (a0)+,d7
  7511.         subq.l    #2,a5                    ;less cycles.
  7512.         eor.b    d7,d3
  7513.         move.w    CCR,d4                    ;status updated.
  7514.  
  7515.         clr.l    h_other_I                ;h = 0! no carry!
  7516.         and.w    #$ff,d3                    ;n = 0!
  7517.  
  7518.         fetch_next_i
  7519.         cnop    0,128
  7520.  
  7521. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7522. ;        CBEE - SET 5, (HL)
  7523. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7524.  
  7525. z80_optc_CBEE:    subq.l    #4,a5
  7526.         move.l    gb_mem_jumps,a6
  7527.  
  7528.         move.w    d2,d7                    ;d7 = a (hl) - write.
  7529.         blt.s    fead_d2_to_d6a
  7530.  
  7531.         move.b    (a3,d2.l),d6
  7532.         or.b    #%100000,d6
  7533.         jsr    ([a6,d2.l*4])                ;memory write.
  7534.  
  7535.         fetch_next_i
  7536.         cnop    0,4
  7537.  
  7538. fead_d2_to_d6a:    move.b    (a2,d2.l),d6                ;ram read.
  7539.         or.b    #%100000,d6
  7540.         jsr    ([a6,d2.l*4])                ;memory write.
  7541.  
  7542.         fetch_next_i
  7543.         cnop    0,128
  7544.  
  7545. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7546. ;        EF - RST 28h
  7547. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7548.  
  7549. z80_optcode_EF:    move.l    a0,d6
  7550.         sub.l    z80_pc_base,d6
  7551.         bsr.l    write_d6_stackx
  7552.  
  7553.         lea    $28(a3),a0
  7554.         subq.l    #8,a5
  7555.         move.l    a3,z80_pc_base
  7556.  
  7557.         fetch_next_i
  7558.         cnop    0,128
  7559.  
  7560. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7561. ;        CBEF - SET 5, A
  7562. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7563.  
  7564. z80_optc_CBEF:    subq.l    #2,a5                    ;less cycles.
  7565.         or.b    #%100000,d3
  7566.         fetch_next_i
  7567.         cnop    0,128
  7568.  
  7569. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7570. ;        F0 - LD A, ($FF00+x)
  7571. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7572.  
  7573. z80_optcode_F0:    move.w    #$ff00,d7                ;custom registers.
  7574.         subq.l    #3,a5
  7575.         move.b    (a0)+,d7
  7576.         move.b    (a2,d7.l),d3                ;ld a, ($ff00+x).
  7577.  
  7578.         fetch_next_i
  7579.         cnop    0,128
  7580.  
  7581. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7582. ;        CBF0 - SET 6, B
  7583. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7584.  
  7585. z80_optc_CBF0:    subq.l    #2,a5                    ;less cycles.
  7586.         or.w    #%0100000000000000,d1
  7587.         fetch_next_i
  7588.         cnop    0,128
  7589.  
  7590. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7591. ;        F1 - POP AF
  7592. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7593.  
  7594. z80_optcode_F1:
  7595.         READW_D5_TO_D7
  7596.         subq.l    #3,a5
  7597.         move.b    d7,d3                    ;a returned.
  7598.         addq.w    #2,d5
  7599.  
  7600.         lsr.w    #8,d7                    ;d7 = f.B (znhc0000).
  7601.         move.b    d7,d6
  7602.         lsr.b    #4,d7                    ;d7 = f.B (0000znhc).
  7603.         move.b    d7,d4
  7604.         and.b    #1,d4                    ;d4 = 0000000c.
  7605.         lsr.b    #1,d7                    ;d7 = 00000znh.
  7606.         and.b    #%100,d7
  7607.         or.b    d7,d4                    ;d4 = mc680x0 flags.
  7608.  
  7609.         move.b    d6,d7
  7610.         and.b    #%00100000,d7                ;d7 = 00h00000.
  7611.         lsr.b    #5,d7
  7612.         move.b    d7,h_the_flag                ;new h!
  7613.         and.w    #%01000000,d6                ;d6 = 0n000000.
  7614.         lsl.w    #2,d6
  7615.         and.w    #$ff,d3
  7616.         or.w    d6,d3                    ;new n!
  7617.  
  7618.         fetch_next_i
  7619.         cnop    0,128
  7620.  
  7621. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7622. ;        CBF1 - SET 6, C
  7623. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7624.  
  7625. z80_optc_CBF1:    subq.l    #2,a5                    ;less cycles.
  7626.         or.b    #%1000000,d1
  7627.         fetch_next_i
  7628.         cnop    0,128
  7629.  
  7630. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7631. ;        F2 - LD A, ($FF00+C)
  7632. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7633.  
  7634. z80_optcode_F2:    move.w    #$ff00,d7                ;custom registers.
  7635.         subq.l    #2,a5                    ;less cycles.
  7636.         move.b    d1,d7                    ;offset.
  7637.         move.b    (a2,d7.l),d3                ;ld a, ($ff00+c).
  7638.  
  7639.         fetch_next_i
  7640.         cnop    0,128
  7641.  
  7642. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7643. ;        CBF2 - SET 6, D
  7644. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7645.  
  7646. z80_optc_CBF2:    subq.l    #2,a5                    ;less cycles.
  7647.         or.w    #%0100000000000000,d0
  7648.         fetch_next_i
  7649.         cnop    0,128
  7650.  
  7651. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7652. ;        F3 - DI (disable interrupts)
  7653. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7654.  
  7655. z80_optcode_F3:    subq.l    #1,a5                    ;less cycles.
  7656.         move.b    #1,i_flag                ;no interrupts.
  7657.  
  7658.         fetch_next_i
  7659.         cnop    0,128
  7660.  
  7661. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7662. ;        CBF3 - SET 6, E
  7663. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7664.  
  7665. z80_optc_CBF3:    subq.l    #2,a5                    ;less cycles.
  7666.         or.b    #%1000000,d0
  7667.         fetch_next_i
  7668.         cnop    0,128
  7669.  
  7670. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7671. ;        F4 - DB $F4 ???
  7672. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7673.  
  7674. z80_optcode_F4:    fetch_next_i
  7675.         cnop    0,128
  7676.  
  7677. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7678. ;        CBF4 - SET 6, H
  7679. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7680.  
  7681. z80_optc_CBF4:    subq.l    #2,a5                    ;less cycles.
  7682.         or.w    #%0100000000000000,d2
  7683.         fetch_next_i
  7684.         cnop    0,128
  7685.  
  7686. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7687. ;        F5 - PUSH AF
  7688. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7689.  
  7690. z80_optcode_F5:    move.b    d3,d6
  7691.         lsl.w    #8,d6
  7692.  
  7693.         move.b    d4,d6                    ;d6 = f.B (000xnzvc).
  7694.         lsl.b    #4,d6                    ;d6 =     (nzvc0000).
  7695.         move.b    d6,d7
  7696.         and.b    #%00010000,d7                ;d7 =     (000c0000).
  7697.         lsl.b    #1,d6                    ;d6 =     (zvc00000).
  7698.         and.b    #%10000000,d6                ;d6 =     (z0000000).
  7699.         or.b    d7,d6                    ;d6 =     (z00c0000).
  7700.                                 ;d6 = af.
  7701.         subq.l    #4,a5
  7702.  
  7703.         move.w    d3,d7
  7704.         lsr.w    #2,d7                    ;d7 = n.
  7705.         and.b    #%01000000,d7
  7706.         or.b    d7,d6                    ;d6 =     (zn0c0000).
  7707.  
  7708.         move.b    h_the_flag,d7                ;h = 0?
  7709.         beq.l    write_d6_stack                ;yes.
  7710.  
  7711.         and.b    #1,d7                    ;d7 = h!
  7712.         beq.l    calculate_h                ;h = x!
  7713.         or.b    #%00100000,d6                ;d6 =     (znhc0000).
  7714.  
  7715.         bra.l    write_d6_stack
  7716.         cnop    0,128
  7717.  
  7718. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7719. ;        CBF5 - SET 6, L
  7720. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7721.  
  7722. z80_optc_CBF5:    subq.l    #2,a5                    ;less cycles.
  7723.         or.b    #%1000000,d2
  7724.         fetch_next_i
  7725.         cnop    0,128
  7726.  
  7727. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7728. ;        F6 - OR x - [n = 0, h = 0, c = 0, z = x]
  7729. ;        MC680x0 CLEARS THE CARRY FLAG ITSELF!
  7730. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7731.  
  7732. z80_optcode_F6:    move.b    (a0)+,d7
  7733.         subq.l    #2,a5                    ;less cycles.
  7734.         or.b    d7,d3
  7735.         move.w    CCR,d4                    ;status updated.
  7736.  
  7737.         clr.l    h_other_I                ;h = 0! no carry!
  7738.         and.w    #$ff,d3                    ;n = 0!
  7739.  
  7740.         fetch_next_i
  7741.         cnop    0,128
  7742.  
  7743. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7744. ;        CBF6 - SET 6, (HL)
  7745. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7746.  
  7747. z80_optc_CBF6:    subq.l    #4,a5
  7748.         move.l    gb_mem_jumps,a6
  7749.  
  7750.         move.w    d2,d7                    ;d7 = a (hl) - write.
  7751.         blt.s    tead_d2_to_d6a
  7752.  
  7753.         move.b    (a3,d2.l),d6
  7754.         or.b    #%1000000,d6
  7755.         jsr    ([a6,d2.l*4])                ;memory write.
  7756.  
  7757.         fetch_next_i
  7758.         cnop    0,4
  7759.  
  7760. tead_d2_to_d6a:    move.b    (a2,d2.l),d6                ;ram read.
  7761.         or.b    #%1000000,d6
  7762.         jsr    ([a6,d2.l*4])                ;memory write.
  7763.  
  7764.         fetch_next_i
  7765.         cnop    0,128
  7766.  
  7767. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7768. ;        F7 - RST 30h
  7769. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7770.  
  7771. z80_optcode_F7:    move.l    a0,d6
  7772.         sub.l    z80_pc_base,d6
  7773.         bsr.l    write_d6_stackx
  7774.  
  7775.         lea    $30(a3),a0
  7776.         subq.l    #8,a5
  7777.         move.l    a3,z80_pc_base
  7778.  
  7779.         fetch_next_i
  7780.         cnop    0,128
  7781.  
  7782. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7783. ;        CBF7 - SET 6, A
  7784. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7785.  
  7786. z80_optc_CBF7:    subq.l    #2,a5                    ;less cycles.
  7787.         or.b    #%1000000,d3
  7788.         fetch_next_i
  7789.         cnop    0,128
  7790.  
  7791. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7792. ;        F8 - LD HL, SP+x - [n = 0, h = x, c = x, z = 0]
  7793. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7794.  
  7795. z80_optcode_F8:    move.w    d5,d2                    ;no h emulation
  7796.         move.b    (a0)+,d7                ;for this optcode. ;(
  7797.         ext.w    d7
  7798.         add.w    d7,d2
  7799.         move.w    CCR,d4
  7800.         subq.l    #3,a5                    ;?
  7801.         and.b    #%1,d4
  7802.  
  7803.         fetch_next_i
  7804.         cnop    0,128
  7805.  
  7806. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7807. ;        CBF8 - SET 7, B
  7808. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7809.  
  7810. z80_optc_CBF8:    subq.l    #2,a5                    ;less cycles.
  7811.         or.w    #%1000000000000000,d1
  7812.         fetch_next_i
  7813.         cnop    0,128
  7814.  
  7815. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7816. ;        F9 - LD SP, HL
  7817. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7818.  
  7819. z80_optcode_F9:    move.w    d2,d5                    ;sp = hl.
  7820.         subq.l    #2,a5                    ;less cycles.
  7821.  
  7822.         fetch_next_i
  7823.         cnop    0,128
  7824.  
  7825. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7826. ;        CBF9 - SET 7, C
  7827. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7828.  
  7829. z80_optc_CBF9:    subq.l    #2,a5                    ;less cycles.
  7830.         or.b    #%10000000,d1
  7831.         fetch_next_i
  7832.         cnop    0,128
  7833.  
  7834. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7835. ;        FA - LD A, (xx)
  7836. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7837.  
  7838. z80_optcode_FA:    move.w    (a0)+,d7
  7839.         subq.l    #4,a5
  7840.         ror.w    #8,d7
  7841.         blt.s    read_d7_to_d3a                ;nope. from ram!
  7842.         move.b    (a3,d7.l),d3
  7843.  
  7844.         fetch_next_i
  7845.         cnop    0,4
  7846.  
  7847. read_d7_to_d3a:    move.b    (a2,d7.l),d3                ;ram read.
  7848.  
  7849.         fetch_next_i
  7850.         cnop    0,128
  7851.  
  7852. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7853. ;        CBFA - SET 7, D
  7854. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7855.  
  7856. z80_optc_CBFA:    subq.l    #2,a5                    ;less cycles.
  7857.         or.w    #%1000000000000000,d0
  7858.         fetch_next_i
  7859.         cnop    0,128
  7860.  
  7861. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7862. ;        FB - EI (enable interrupts)
  7863. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7864.  
  7865. z80_optcode_FB:    subq.l    #1,a5
  7866.         tst.b    i_flag
  7867.         beq.s    z80_optcode_FB_exit
  7868.         clr.b    i_flag                    ;interrupts enabled.
  7869.  
  7870.         move.l    a5,z80_cycles_left
  7871.         move.l    #1,a5
  7872.         move.b    #1,z80_ei_return
  7873.  
  7874. z80_optcode_FB_exit:
  7875.         fetch_next_i
  7876.         cnop    0,128
  7877.  
  7878. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7879. ;        CBFB - SET 7, E
  7880. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7881.  
  7882. z80_optc_CBFB:    subq.l    #2,a5                    ;less cycles.
  7883.         or.b    #%10000000,d0
  7884.         fetch_next_i
  7885.         cnop    0,128
  7886.  
  7887. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7888. ;        FC - DB $FC ???
  7889. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7890.  
  7891. z80_optcode_FC:    fetch_next_i
  7892.         cnop    0,128
  7893.  
  7894. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7895. ;        CBFC - SET 7, H
  7896. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7897.  
  7898. z80_optc_CBFC:    subq.l    #2,a5                    ;less cycles.
  7899.         or.w    #%1000000000000000,d2
  7900.         fetch_next_i
  7901.         cnop    0,128
  7902.  
  7903. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7904. ;        FD - DB $FD ???
  7905. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7906.  
  7907. z80_optcode_FD:    fetch_next_i
  7908.         cnop    0,128
  7909.  
  7910. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7911. ;        CBFD - SET 7, L
  7912. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7913.  
  7914. z80_optc_CBFD:    subq.l    #2,a5                    ;less cycles.
  7915.         or.b    #%10000000,d2
  7916.         fetch_next_i
  7917.         cnop    0,128
  7918.  
  7919. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7920. ;        FE - CP x - [n = 1, h = x, c = x, z = x]
  7921. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7922.  
  7923. z80_optcode_FE:    move.b    (a0)+,d6
  7924.         move.b    d3,h_other_I
  7925.         subq.l    #2,a5
  7926.         move.b    d6,h_other_II
  7927.  
  7928.         cmp.b    d6,d3
  7929.         move.w    CCR,d4                    ;status updated.
  7930.  
  7931.         move.w    #$0002,h_with_carry            ;no carry! h = x!
  7932.         or.w    #$100,d3                ;n = 1!
  7933.  
  7934.         fetch_next_i
  7935.         cnop    0,128
  7936.  
  7937. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7938. ;        CBFE - SET 7, (HL)
  7939. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7940.  
  7941. z80_optc_CBFE:    subq.l    #4,a5
  7942.         move.l    gb_mem_jumps,a6
  7943.  
  7944.         move.w    d2,d7                    ;d7 = a (hl) - write.
  7945.         blt.s    uead_d2_to_d6a
  7946.  
  7947.         move.b    (a3,d2.l),d6
  7948.         or.b    #%10000000,d6
  7949.         jsr    ([a6,d2.l*4])                ;memory write.
  7950.  
  7951.         fetch_next_i
  7952.         cnop    0,4
  7953.  
  7954. uead_d2_to_d6a:    move.b    (a2,d2.l),d6                ;ram read.
  7955.         or.b    #%10000000,d6
  7956.         jsr    ([a6,d2.l*4])                ;memory write.
  7957.  
  7958.         fetch_next_i
  7959.         cnop    0,128
  7960.  
  7961. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7962. ;        FF - RST 38h
  7963. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7964.  
  7965. z80_optcode_FF:    move.l    a0,d6
  7966.         sub.l    z80_pc_base,d6
  7967.         bsr.l    write_d6_stackx
  7968.  
  7969.         lea    $38(a3),a0
  7970.         subq.l    #8,a5
  7971.         move.l    a3,z80_pc_base
  7972.  
  7973.         fetch_next_i
  7974.         cnop    0,128
  7975.  
  7976. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7977. ;        CBFF - SET 7, A
  7978. ;««««««««««««««««««««««««««««««««««««««««««««««»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»»
  7979.  
  7980. z80_optc_CBFF:    subq.l    #2,a5                    ;less cycles.
  7981.         or.b    #%10000000,d3
  7982.         fetch_next_i
  7983.         cnop    0,128
  7984.